Skip to content

Conversation

@brandtbucher
Copy link
Member

Fixes #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.

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 in testcheck.py that will emit a warning when it's safe to unskip these tests.

Copy link
Collaborator

@JukkaL JukkaL left a 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:
Copy link
Collaborator

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.

@brandtbucher
Copy link
Member Author

Thanks for the suggestion @JukkaL! I've included the new test in my patch.

Copy link
Collaborator

@JukkaL JukkaL left a 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!

@JukkaL
Copy link
Collaborator

JukkaL commented May 31, 2019

I verified manually that the tests pass on Python 3.8a4.

@JukkaL JukkaL merged commit 848a78d into python:master May 31, 2019
@brandtbucher brandtbucher deleted the pep570 branch May 31, 2019 14:05
ilevkivskyi pushed a commit that referenced this pull request Jun 2, 2019
The `3.8-dev` Travis build environment now uses Python 3.8.0a4+!

This is left over from #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).
PattenR pushed a commit to PattenR/mypy that referenced this pull request Jun 23, 2019
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+.
PattenR pushed a commit to PattenR/mypy that referenced this pull request Jun 23, 2019
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support 3.8 positional-only arguments

2 participants