Support positional and keyword-only arguments#18762
Support positional and keyword-only arguments#18762hauntsaninja merged 3 commits intopython:masterfrom
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 |
| None, | ||
| ) | ||
|
|
||
| def test_infer_sig_from_docstring_args_kwargs(self) -> None: |
There was a problem hiding this comment.
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.
hauntsaninja
left a comment
There was a problem hiding this comment.
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
hauntsaninja
left a comment
There was a problem hiding this comment.
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
ArgSigorFunctionSigclasses, since the information would not be used anyway.