Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[used before def] handle walrus declaration in match subject correctly#14665

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JukkaL merged 2 commits intopython:masterfromilinum:fix-match-walrus
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
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
NextNext commit
[used before def] handle walrus declaration in match subject correctly
  • Loading branch information
@ilinum
ilinum committedFeb 9, 2023
commite4d51c55974dd78159568f10c4b15a5da6600510
2 changes: 1 addition & 1 deletionmypy/partially_defined.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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
14 changes: 14 additions & 0 deletionstest-data/unit/check-python310.test
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1813,6 +1813,20 @@ 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

[8]ページ先頭

©2009-2025 Movatter.jp