-
-
Notifications
You must be signed in to change notification settings - Fork 11k
Keyword-only arguments in compat/_inspect.py #16542
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
Comments
Nevermind, I see now. |
surculus12/numpy@edd97f9 is the proposed change:
|
The docstring for |
Sorry about the late reply. Should I replace the usages of Would you like to deprecate |
@surculus12 I haven't investigated myself so I can't say, but if you're willing to look into it and see if there aren't any other sticking-points/descrepancies I think it would be an improvement if we could move towards the Python |
+1 for revisiting using the builtin |
Closing, the module is removed. (Or at least being removed) EDIT: Seems we still use the incorrect version internally, should probaly just use |
Uh oh!
There was an error while loading. Please reload this page.
There was an issue (#16299) that was caused by the
get
functions innumpy.compat._inspect
not handling keyword-only arguments (PEP 3102 asterisk style). The functions would ignore the keyword-only arguments, which either lead to incomplete or incorrect output.#16541 fixed this issue partially. However, I missed two issues:
verify_matching_signatures(lambda a, *, foo=1: 0, lambda a, foo=None: 0)
will pass because it treatsfoo
the same, regardless of whether it is kwonly. This is probably not the intended behaviour. As such, arguments that are keyword-only would need to be treated differently from those that are not, which would require changing the return of the function.formatargspec
andformatargvalues
do not handle kwonly arguments, similar to above. As such,format(get(...))
would strip out the kwonly property of arguments. Since this method is used to establish signatures elsewhere, it is probably not the intended behaviour. Fixing this would require changing the arguments of theformat
functions to match the change discussed above.Since this would require changing the signatures of these functions, I'd like some input on whether this should be done. The proposal would be to modify the functions as follows:
And similarly, the signatures of
format
:This should not interfere with anything, unless it was relying on incorrect behaviour by ignoring kwonly arguments. The usages that pycharm detects are:
formatargspec
:numpy.ma.core.get_object_signature
which is simplyformatargspec(*getargspec(obj))
and will remain unaffected.formatargvalues
:getargspec
:numpy.core.overrides.verify_matching_signatures
will be fixed as per issue BUG: numpy.core.overrides.verify_matching_signatures ignores keyword-only arguments #16299numpy.ma.core.get_object_signature
unaffected as per theformatargspec
usage.getargs
:numpy.compat._inspect.getargspec
is being fixed, changing returnsnumpy.compat._inspect.getargvalues
would probably also need to have returns changed, though I cannot see any usageI'm not familiar enough with the project to know whether there are could be any usages that can't be detected.
If this seems like a reasonable change I will add it and create a PR.
The text was updated successfully, but these errors were encountered: