Skip to content

Commit 769ea41

Browse files
authored
Merge pull request #640 from eddieantonio/fix-variable-annotations
Fix variable annotations
2 parents 454e035 + a46c7a6 commit 769ea41

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

pycodestyle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
132132
OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)')
133133
LAMBDA_REGEX = re.compile(r'\blambda\b')
134134
HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$')
135-
STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)')
135+
STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)\b')
136136
STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def\s+|def\s+|class\s+|@)')
137137
STARTSWITH_INDENT_STATEMENT_REGEX = re.compile(
138-
r'^\s*({0})'.format('|'.join(s.replace(' ', r'\s+') for s in (
138+
r'^\s*({0})\b'.format('|'.join(s.replace(' ', r'\s+') for s in (
139139
'def', 'async def',
140140
'for', 'async for',
141141
'if', 'elif', 'else',

testsuite/python3.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,28 @@ def foo(x: int) -> int:
1212

1313

1414
class Class:
15+
# Camel-caes
1516
cls_var: ClassVar[str]
17+
for_var: ClassVar[str]
18+
while_var: ClassVar[str]
19+
def_var: ClassVar[str]
20+
if_var: ClassVar[str]
21+
elif_var: ClassVar[str]
22+
else_var: ClassVar[str]
23+
try_var: ClassVar[str]
24+
except_var: ClassVar[str]
25+
finally_var: ClassVar[str]
26+
with_var: ClassVar[str]
27+
forVar: ClassVar[str]
28+
whileVar: ClassVar[str]
29+
defVar: ClassVar[str]
30+
ifVar: ClassVar[str]
31+
elifVar: ClassVar[str]
32+
elseVar: ClassVar[str]
33+
tryVar: ClassVar[str]
34+
exceptVar: ClassVar[str]
35+
finallyVar: ClassVar[str]
36+
withVar: ClassVar[str]
1637

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

0 commit comments

Comments
 (0)