Skip to content

Check all blocks for overloads in the fast parser #1718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def from_comp_operator(self, op: ast35.cmpop) -> str:
def as_block(self, stmts: List[ast35.stmt], lineno: int) -> Block:
b = None
if stmts:
b = Block(self.visit_list(stmts))
b = Block(self.fix_function_overloads(self.visit_list(stmts)))
b.set_line(lineno)
return b

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

cdef = ClassDef(n.name,
Block(self.fix_function_overloads(self.visit_list(n.body))),
self.as_block(n.body, n.lineno),
None,
self.visit_list(n.bases),
metaclass=metaclass)
Expand Down
19 changes: 19 additions & 0 deletions test-data/unit/check-fastparse.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,22 @@ def f(): # E: syntax error in type comment
def f(): # E: invalid type comment
# type: (a + b) -> None
pass

[case testFastParseProperty]
# flags: fast-parser
class C:
@property
def x(self) -> str: pass
@x.setter
def x(self, value: str) -> None: pass
[builtins fixtures/property.py]

[case testFastParseConditionalProperty]
# flags: fast-parser
class C:
if 1:
@property
def x(self) -> str: pass
@x.setter
def x(self, value: str) -> None: pass
[builtins fixtures/property.py]