Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Fix kwonly args ignored in compat/_inspect.py #16541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

surculus12
Copy link

Fixes #16299 . The issue was with numpy.compat._inspect.py ignoring keyword-only arguments. This caused incomplete and even incorrect output in the inspection functions (example in issue), which was the root-cause for numpy.core.overrides.verify_matching_signatures ignoring keyword-only arguments.

I can't imagine this slowing the import in any meaningful way, but I'm not completely familiar with the optimization being done with the file in general. If someone has a better way of handing the function.__defaults__ and function__kwdefaults__ tuples, that would be nice. Since either can be None, I had to perform those if blocks. I cannot recall any smoother ways of combining them.

I would have liked to add tests to this, but there don't seem to be any tests for this module. I assume this is related to the import optimization.

@surculus12 surculus12 closed this Jun 9, 2020
@eric-wieser
Copy link
Member

Did you mean to close this?

@surculus12
Copy link
Author

@eric-wieser Yes, there are some further issues here. I am creating a new issue for a better discussion into handling keyword-only arguments inside compat/_inspect.py (or I can continue it on your issue?). They will likely need to be treated independent from the args, since otherwise the following signatures will also be equivalent:

(a *, foo=None) and (a, foo=None)

Further, the format functions likely need to be able to reverse this properly, without lowing the "kwonly-ness" of those parameters. It is used to establish signatures elsewhere.

@surculus12
Copy link
Author

See #16542

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: numpy.core.overrides.verify_matching_signatures ignores keyword-only arguments
2 participants