-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
PEP 570: Positional-Only Arguments #6900
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
JukkaL
left a comment
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 implementing this! This gets us closer to Python 3.8 compatibility.
Looks good, just one idea for a test case.
| f(arg="ERROR") # E: Unexpected keyword argument "arg" for "f" | ||
|
|
||
| [case testPEP570Signatures1-skip] | ||
| def f(p1: bytes, p2: float, /, p_or_kw: int, *, kw: str) -> 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.
Try also calling f with valid and invalid arguments. For example, make sure p1 is not a valid keyword argument but p_or_kw is both a valid positional and keyword argument, and kw must be a keyword argument.
|
Thanks for the suggestion @JukkaL! I've included the new test in my patch. |
JukkaL
left a comment
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 update!
|
I verified manually that the tests pass on Python 3.8a4. |
Fixes python#6878. This was actually much more straightforward than I anticipated; since we already support `__some` forms of positional-only arguments, it was just a matter of adding a couple of lines to properly pick up the new `posonlyargs` attribute from the AST. Skip PEP 570 tests until Travis supports 3.8.0a4+.
The `3.8-dev` Travis build environment now uses Python 3.8.0a4+! This is left over from python#6900. We aren't running 3.8 test right now for other reasons, but I've confirmed that these pass fine on my local build (@JukkaL confirmed too in the PR).
Fixes #6878. This was actually much more straightforward than I anticipated; since we already support
__someforms of positional-only arguments, it was just a matter of adding a couple of lines to properly pick up the newposonlyargsattribute from the AST.The tricky part is the tests. Travis doesn't currently have any build environments for 3.8.0a4 (even the
python: "nightly"image is only 3.8.0a3+... 😐), so these tests fail with syntax errors. I've skipped them for now, but they pass fine on my local Python build. I added a small check intestcheck.pythat will emit a warning when it's safe to unskip these tests.