Skip to content

Commit 9726e10

Browse files
authored
Merge pull request PyCQA#875 from asottile/ellipsis_not_binary_operator
Ellipsis is not a binary operator
2 parents 3b258c3 + 4fea946 commit 9726e10

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pycodestyle.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1205,13 +1205,16 @@ def explicit_line_join(logical_line, tokens):
12051205
parens -= 1
12061206

12071207

1208+
_SYMBOLIC_OPS = frozenset("()[]{},:.;@=%~") | frozenset(("...",))
1209+
1210+
12081211
def _is_binary_operator(token_type, text):
12091212
is_op_token = token_type == tokenize.OP
12101213
is_conjunction = text in ['and', 'or']
12111214
# NOTE(sigmavirus24): Previously the not_a_symbol check was executed
12121215
# conditionally. Since it is now *always* executed, text may be
12131216
# None. In that case we get a TypeError for `text not in str`.
1214-
not_a_symbol = text and text not in "()[]{},:.;@=%~"
1217+
not_a_symbol = text and text not in _SYMBOLIC_OPS
12151218
# The % character is strictly speaking a binary operator, but the
12161219
# common usage seems to be to put it next to the format parameters,
12171220
# after a line break.

testsuite/python3.py

+7
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ class Class:
3737

3838
def m(self):
3939
xs: List[int] = []
40+
41+
42+
# Used to trigger W504
43+
def f(
44+
x: str = ...
45+
):
46+
...

0 commit comments

Comments
 (0)