Skip to content

Commit

Permalink
Merge pull request #875 from asottile/ellipsis_not_binary_operator
Browse files Browse the repository at this point in the history
Ellipsis is not a binary operator
  • Loading branch information
sigmavirus24 authored Jul 11, 2019
2 parents 3b258c3 + 4fea946 commit 9726e10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,13 +1205,16 @@ def explicit_line_join(logical_line, tokens):
parens -= 1


_SYMBOLIC_OPS = frozenset("()[]{},:.;@=%~") | frozenset(("...",))


def _is_binary_operator(token_type, text):
is_op_token = token_type == tokenize.OP
is_conjunction = text in ['and', 'or']
# NOTE(sigmavirus24): Previously the not_a_symbol check was executed
# conditionally. Since it is now *always* executed, text may be
# None. In that case we get a TypeError for `text not in str`.
not_a_symbol = text and text not in "()[]{},:.;@=%~"
not_a_symbol = text and text not in _SYMBOLIC_OPS
# The % character is strictly speaking a binary operator, but the
# common usage seems to be to put it next to the format parameters,
# after a line break.
Expand Down
7 changes: 7 additions & 0 deletions testsuite/python3.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ class Class:

def m(self):
xs: List[int] = []


# Used to trigger W504
def f(
x: str = ...
):
...

0 comments on commit 9726e10

Please sign in to comment.