File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 123
123
HUNK_REGEX = re .compile (r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$' )
124
124
STARTSWITH_DEF_REGEX = re .compile (r'^(async\s+def|def)' )
125
125
STARTSWITH_TOP_LEVEL_REGEX = re .compile (r'^(async\s+def|def|class|@)' )
126
+ STARTSWITH_INDENT_STATEMENT_REGEX = re .compile (
127
+ r'^\s*({0})' .format ('|' .join (s .replace (' ' , '\s+' ) for s in (
128
+ 'def' , 'async def' ,
129
+ 'for' , 'async for' ,
130
+ 'if' , 'elif' , 'else' ,
131
+ 'try' , 'except' , 'finally' ,
132
+ 'with' , 'async with' ,
133
+ 'class' ,
134
+ 'while' ,
135
+ )))
136
+ )
126
137
127
138
# Work around Python < 2.6 behaviour, which does not generate NL after
128
139
# a comment which is on a line by itself.
@@ -1004,7 +1015,7 @@ def compound_statements(logical_line):
1004
1015
break
1005
1016
if STARTSWITH_DEF_REGEX .match (line ):
1006
1017
yield 0 , "E704 multiple statements on one line (def)"
1007
- else :
1018
+ elif STARTSWITH_INDENT_STATEMENT_REGEX . match ( line ) :
1008
1019
yield found , "E701 multiple statements on one line (colon)"
1009
1020
prev_found = found
1010
1021
found = line .find (':' , found + 1 )
Original file line number Diff line number Diff line change 8
8
pass
9
9
except :
10
10
print 'Whoops'
11
- #: E122 E225 E251 E251 E701
11
+ #: E122 E225 E251 E251
12
12
13
13
# Do not crash if code is invalid
14
14
if msg :
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python3
2
+ from typing import ClassVar , List
2
3
3
4
4
5
# Annotated function (Issue #29)
5
6
def foo (x : int ) -> int :
6
7
return x + 1
8
+
9
+
10
+ # Annotated variables #575
11
+ CONST : int = 42
12
+
13
+
14
+ class Class :
15
+ cls_var : ClassVar [str ]
16
+
17
+ def m (self ):
18
+ xs : List [int ] = []
You can’t perform that action at this time.
0 commit comments