Skip to content

Commit

Permalink
handle functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ilinum committed Nov 27, 2022
1 parent 0b8ffe3 commit 3c5d21e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mypy/partially_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def visit_match_stmt(self, o: MatchStmt) -> None:
self.tracker.end_branch_statement()

def visit_func_def(self, o: FuncDef) -> None:
self.tracker.record_definition(o.name)
self.process_definition(o.name)
self.tracker.enter_scope()
super().visit_func_def(o)
self.tracker.exit_scope()
Expand Down
5 changes: 5 additions & 0 deletions test-data/unit/check-partially-defined.test
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ def f(x: A):
y = A() # E: Name "A" is used before definition

class A: pass

[case testUseBeforeDefFunc]
# flags: --enable-error-code partially-defined --enable-error-code use-before-def
foo() # E: Name "foo" is used before definition
def foo(): pass
[case testGenerator]
# flags: --enable-error-code partially-defined
if int():
Expand Down

0 comments on commit 3c5d21e

Please sign in to comment.