Skip to content

gh-162668: preserve keywords matching omitted positional-only parameters in inspect - #162669

Open
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-inspect-bind-omitted-posonly
Open

tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:fix-inspect-bind-omitted-posonly

Conversation

@tonghuaroot

@tonghuaroot tonghuaroot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

keep keywords matching omitted positional only parameters in the keyword arguments dictionary.

closes #162668.

return x, y, options

bound = inspect.signature(f).bind(y=2)
bound.apply_defaults()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, assert .args and .kwargs before .apply_defaults as well.


bound = inspect.signature(f).bind(y=2)
bound.apply_defaults()
self.assertEqual(f(*bound.args, **bound.kwargs), f(y=2))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, assert the result of inspect.signature(f).bind(3, 4, y=5) here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

signature.bind assigns a keyword to an omitted positional only parameter

2 participants