-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Support positional and keyword-only arguments #18762
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
Currently the signature parsing logic fails when confronted with a `/` or a `*`, rather than recognizing them as demarcating positional-only and keyword-only arguments. This patch supports parsing signatures with these features, but doesn't pass this information along to the `ArgSig` or `FunctionSig` classes, since the information would not be used anyway.
This comment has been minimized.
This comment has been minimized.
This PR was triggered because I noticed that a very recent version of |
@@ -399,6 +399,101 @@ def test_infer_sig_from_docstring_bad_indentation(self) -> None: | |||
None, | |||
) | |||
|
|||
def test_infer_sig_from_docstring_args_kwargs(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context: This behavior is not actually changing, but an intermediate version of the code would have failed these tests, and I only noticed this because the pybind11
stubgen tests started failing, so I figured I would add tests for this proactively.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not familiar with this code, but is the keyword_only
int handled correctly if there's a *args
arg as opposed to just *, kw, ...)
?
I guess not, it should be the following entry. I've fixed that and added some more test cases for this and other args/kwargs related thing. It seems like some of the rules around |
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
These stubs are generated by cherry-picking in python/mypy#18762 to mypy 1.13.0 PiperOrigin-RevId: 734567518
These stubs are generated by cherry-picking in python/mypy#18762 to mypy 1.13.0 FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#23553 from olupton:remove-unused-include 970f55f476a9b4bf2dcb829152d4104f21864436 PiperOrigin-RevId: 734567518
These stubs are generated by cherry-picking in python/mypy#18762 to mypy 1.13.0 PiperOrigin-RevId: 735413074
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the improvement!
Currently the signature parsing logic fails when confronted with a
/
or a*
, rather than recognizing them as demarcating positional-only and keyword-only arguments.This patch supports parsing signatures with these features, but doesn't pass this information along to the
ArgSig
orFunctionSig
classes, since the information would not be used anyway.