Skip to content
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
2 changes: 1 addition & 1 deletion mypy/partially_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ def visit_if_stmt(self, o: IfStmt) -> None:
self.tracker.end_branch_statement()

def visit_match_stmt(self, o: MatchStmt) -> None:
self.tracker.start_branch_statement()
o.subject.accept(self)
self.tracker.start_branch_statement()
for i in range(len(o.patterns)):
pattern = o.patterns[i]
pattern.accept(self)
Expand Down
13 changes: 13 additions & 0 deletions test-data/unit/check-python310.test
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,19 @@ def f1(x: int) -> int:

[typing fixtures/typing-medium.pyi]

[case testUsedBeforeDefMatchWalrus]
# flags: --enable-error-code used-before-def
import typing

def f0(x: int) -> None:
a = y # E: Cannot determine type of "y" # E: Name "y" is used before definition
match y := x:
case 1:
b = y
case 2:
c = y
d = y

[case testTypeAliasWithNewUnionSyntaxAndNoneLeftOperand]
from typing import overload
class C:
Expand Down