Skip to content

Added support for PEP 570 (#867) - #872

Merged
sigmavirus24 merged 5 commits into
PyCQA:masterfrom
sandsbit:master
Jan 30, 2020
Merged

Added support for PEP 570 (#867)#872
sigmavirus24 merged 5 commits into
PyCQA:masterfrom
sandsbit:master

Conversation

@sandsbit

@sandsbit sandsbit commented Jul 1, 2019

Copy link
Copy Markdown
Contributor

@asottile asottile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code seems fine, can you make testsuite/python38.py with:

def f(a, /, b):
    pass

@asottile

Copy link
Copy Markdown
Member

fwiw, this patch also fixes the problem, I don't know which one is more correct (there other "unary operators" covering the splat / etc. operations in this list (it's how named-only arguments aren't flagged):

diff --git a/pycodestyle.py b/pycodestyle.py
index 6ad5456..a0c2898 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -112,7 +112,7 @@ REPORT_FORMAT = {
 PyCF_ONLY_AST = 1024
 SINGLETONS = frozenset(['False', 'None', 'True'])
 KEYWORDS = frozenset(keyword.kwlist + ['print', 'async']) - SINGLETONS
-UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
+UNARY_OPERATORS = frozenset(['>>', '**', '*', '/', '+', '-'])
 ARITHMETIC_OP = frozenset(['**', '*', '/', '//', '+', '-'])
 WS_OPTIONAL_OPERATORS = ARITHMETIC_OP.union(['^', '&', '|', '<<', '>>', '%'])
 # Warn for -> function annotation operator in py3.5+ (issue 803)
diff --git a/testsuite/python38.py b/testsuite/python38.py
new file mode 100644
index 0000000..2132cd5
--- /dev/null
+++ b/testsuite/python38.py
@@ -0,0 +1,2 @@
+def f(a, /, b):
+    pass

@mikeholler

Copy link
Copy Markdown

Any updates on this? I'm having issues as well.

@aviramha

Copy link
Copy Markdown

code seems fine, can you make testsuite/python38.py with:

def f(a, /, b):
    pass

Seems author is stale, should I/anyone else just create a new PR with a test added?

@sandsbit

Copy link
Copy Markdown
Contributor Author

I will add tests tonight

@aviramha

Copy link
Copy Markdown

Any update?

Comment thread testsuite/python38 Outdated
@@ -0,0 +1,3 @@
#: Okay

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be python38.py

Comment thread pycodestyle.py Outdated
sandsbit and others added 2 commits January 22, 2020 20:21
Co-Authored-By: Anthony Sottile <asottile@umich.edu>

@asottile asottile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems fine to me, a smaller patch however:

-UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
+UNARY_OPERATORS = frozenset(['>>', '**', '*', '/', '+', '-'])

(this is how keyword-only arguments are handled currently)

@asottile

Copy link
Copy Markdown
Member

actually, looks like you'll need to rebase now since python38.py got created on master

@sandsbit

sandsbit commented Jan 22, 2020

Copy link
Copy Markdown
Contributor Author

this seems fine to me, a smaller patch however:

-UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
+UNARY_OPERATORS = frozenset(['>>', '**', '*', '/', '+', '-'])

I think it is not a good idea 'cause in this case '/' is not an unary operator

@asottile

Copy link
Copy Markdown
Member

this seems fine to me, a smaller patch however:

-UNARY_OPERATORS = frozenset(['>>', '**', '*', '+', '-'])
+UNARY_OPERATORS = frozenset(['>>', '**', '*', '/', '+', '-'])

(this is how keyword-only arguments are handled currently)
I think it is not a good idea 'cause in this case '/' is not an unary operator

neither is >> nor * nor **

@FichteFoll

Copy link
Copy Markdown
Contributor

* and ** kinda are unary for unpacking, but they aren't operators in that case. I have no idea why >> is in that list, however.

Either way, since * and ** are allowed for unpacking in quite a few situations, it kind of makes sense to have them in that list, but / is really only valid in the parameter list and the suggested patch is more targeted and thus makes more sense to me.

@asottile

Copy link
Copy Markdown
Member

>> is probably for python 2

@jakabk

jakabk commented Jan 29, 2020

Copy link
Copy Markdown

Waiting for release

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.

7 participants