--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/pycodestyle.py Fri Aug 02 18:02:56 2024 +0200 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/pycodestyle.py Fri Aug 02 19:12:15 2024 +0200 @@ -84,7 +84,7 @@ ): # pragma: no cover (<py310) tokenize._compile = lru_cache(tokenize._compile) # type: ignore -__version__ = '2.11.1-eric' +__version__ = '2.12.0-eric' DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git,__pycache__,.tox' DEFAULT_IGNORE = 'E121,E123,E126,E226,E24,E704,W503,W504' @@ -136,14 +136,15 @@ ERRORCODE_REGEX = re.compile(r'\b[A-Z]\d{3}\b') DOCSTRING_REGEX = re.compile(r'u?r?["\']') EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[\[({][ \t]|[ \t][\]}),;:](?!=)') +WHITESPACE_AFTER_DECORATOR_REGEX = re.compile(r'@\s') WHITESPACE_AFTER_COMMA_REGEX = re.compile(r'[,;:]\s*(?: |\t)') COMPARE_SINGLETON_REGEX = re.compile(r'(\bNone|\bFalse|\bTrue)?\s*([=!]=)' r'\s*(?(1)|(None|False|True))\b') COMPARE_NEGATIVE_REGEX = re.compile(r'\b(?<!is\s)(not)\s+[^][)(}{ ]+\s+' r'(in|is)\s') COMPARE_TYPE_REGEX = re.compile( - r'[=!]=\s+type(?:\s*\(\s*([^)]*[^ )])\s*\))' - r'|\btype(?:\s*\(\s*([^)]*[^ )])\s*\))\s+[=!]=' + r'[=!]=\s+type(?:\s*\(\s*([^)]*[^\s)])\s*\))' + r'|(?<!\.)\btype(?:\s*\(\s*([^)]*[^\s)])\s*\))\s+[=!]=' ) KEYWORD_REGEX = re.compile(r'(\s*)\b(?:%s)\b(\s*)' % r'|'.join(KEYWORDS)) OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+|:=)(\s*)') @@ -466,6 +467,9 @@ E203: if x == 4: print x, y; x, y = y , x E203: if x == 4: print x, y ; x, y = y, x E203: if x == 4 : print x, y; x, y = y, x + + Okay: @decorator + E204: @ decorator """ line = logical_line for match in EXTRANEOUS_WHITESPACE_REGEX.finditer(line): @@ -479,6 +483,8 @@ code = ('E202' if char in '}])' else 'E203') # if char in ',;:' yield found, f"{code} whitespace before '{char}'", char + if WHITESPACE_AFTER_DECORATOR_REGEX.match(logical_line): + yield 1, "E204 whitespace after decorator '@'" @register_check def whitespace_around_keywords(logical_line): @@ -1297,6 +1303,8 @@ comment = True if start[0] != prev_start and parens and backslash and not comment: yield backslash, "E502 the backslash is redundant between brackets" + if start[0] != prev_start: + comment = False # Reset comment flag on newline if end[0] != prev_end: if line.rstrip('\r\n').endswith('\\'): backslash = (end[0], len(line.splitlines()[-1]) - 1)