Skip to content

Commit ef5e7c5

Browse files
ddfishergvanrossum
authored andcommitted
Check all blocks for overloads in the fast parser (#1718)
Fixes #1708.
1 parent 09268cb commit ef5e7c5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

mypy/fastparse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def from_comp_operator(self, op: ast35.cmpop) -> str:
176176
def as_block(self, stmts: List[ast35.stmt], lineno: int) -> Block:
177177
b = None
178178
if stmts:
179-
b = Block(self.visit_list(stmts))
179+
b = Block(self.fix_function_overloads(self.visit_list(stmts)))
180180
b.set_line(lineno)
181181
return b
182182

@@ -353,7 +353,7 @@ def visit_ClassDef(self, n: ast35.ClassDef) -> Node:
353353
metaclass = self.stringify_name(metaclass_arg.value)
354354

355355
cdef = ClassDef(n.name,
356-
Block(self.fix_function_overloads(self.visit_list(n.body))),
356+
self.as_block(n.body, n.lineno),
357357
None,
358358
self.visit_list(n.bases),
359359
metaclass=metaclass)

test-data/unit/check-fastparse.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,22 @@ def f(): # E: syntax error in type comment
2323
def f(): # E: invalid type comment
2424
# type: (a + b) -> None
2525
pass
26+
27+
[case testFastParseProperty]
28+
# flags: fast-parser
29+
class C:
30+
@property
31+
def x(self) -> str: pass
32+
@x.setter
33+
def x(self, value: str) -> None: pass
34+
[builtins fixtures/property.py]
35+
36+
[case testFastParseConditionalProperty]
37+
# flags: fast-parser
38+
class C:
39+
if 1:
40+
@property
41+
def x(self) -> str: pass
42+
@x.setter
43+
def x(self, value: str) -> None: pass
44+
[builtins fixtures/property.py]

0 commit comments

Comments
 (0)