diff options
-rwxr-xr-x | pycodestyle.py | 15 | ||||
-rw-r--r-- | testsuite/python38.py | 17 |
2 files changed, 24 insertions, 8 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index b00b1f1..cc1720e 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -169,7 +169,7 @@ STARTSWITH_INDENT_STATEMENT_REGEX = re.compile( 'while', ))) ) -DUNDER_REGEX = re.compile(r'^__([^\s]+)__ = ') +DUNDER_REGEX = re.compile(r"^__([^\s]+)__(?::\s*[a-zA-Z.0-9_\[\]\"]+)? = ") MATCH_CASE_REGEX = re.compile(r'^\s*\b(?:match|case)(\s*)(?=.*\:)') BLANK_EXCEPT_REGEX = re.compile(r"except\s*:") @@ -564,7 +564,7 @@ def missing_whitespace(logical_line): @register_check def indentation(logical_line, previous_logical, indent_char, indent_level, previous_indent_level, - indent_size, indent_size_str): + indent_size): r"""Use indent_size (PEP8 says 4) spaces per indentation level. For really old code that you don't want to mess up, you can continue @@ -588,7 +588,7 @@ def indentation(logical_line, previous_logical, indent_char, if indent_level % indent_size: yield 0, tmpl % ( 1 + c, - "indentation is not a multiple of " + indent_size_str, + "indentation is not a multiple of " + str(indent_size), ) indent_expect = previous_logical.endswith(':') if indent_expect and indent_level <= previous_indent_level: @@ -605,8 +605,7 @@ def indentation(logical_line, previous_logical, indent_char, @register_check def continued_indentation(logical_line, tokens, indent_level, hang_closing, - indent_char, indent_size, indent_size_str, noqa, - verbose): + indent_char, indent_size, noqa, verbose): r"""Continuation lines indentation. Continuation lines should align wrapped elements either vertically @@ -933,7 +932,9 @@ def missing_whitespace_around_operator(logical_line, tokens): # ^ # def f(a, b, /): # ^ - prev_text == '/' and text in {',', ')'} or + # f = lambda a, /: + # ^ + prev_text == '/' and text in {',', ')', ':'} or # def f(a, b, /): # ^ prev_text == ')' and text == ':' @@ -2002,8 +2003,6 @@ class Checker(object): self.multiline = False # in a multiline string? self.hang_closing = options.hang_closing self.indent_size = options.indent_size - self.indent_size_str = ({2: 'two', 4: 'four', 8: 'eight'} - .get(self.indent_size, str(self.indent_size))) self.verbose = options.verbose self.filename = filename # Dictionary where a checker can store its custom state. diff --git a/testsuite/python38.py b/testsuite/python38.py index 57ee613..1374192 100644 --- a/testsuite/python38.py +++ b/testsuite/python38.py @@ -13,6 +13,9 @@ def f3( b, ): pass + + +lambda a, /: None #: Okay if x := 1: print(x) @@ -25,3 +28,17 @@ if x:= 1: #: E225:1:18 if False or (x :=1): pass +#: Okay +import typing as t + +__all__: t.List[str] = [] + +import logging + +logging.getLogger(__name__) +#: E402 +import typing as t + +all_the_things: t.List[str] = [] + +import logging |