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] correctly handle walrus operator#14646

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 1 commit intopython:masterfromilinum:mypy/handle-walrus
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes fromall 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
[used before def] correctly handle walrus operator
  • Loading branch information
@ilinum
ilinum committedFeb 8, 2023
commitb5e5502b812f8c9be31fa602b0de1890a3e199e4
2 changes: 1 addition & 1 deletionmypy/traverser.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -253,9 +253,9 @@ def visit_yield_expr(self, o: YieldExpr) -> None:
o.expr.accept(self)

def visit_call_expr(self, o: CallExpr) -> None:
o.callee.accept(self)
for a in o.args:
a.accept(self)
o.callee.accept(self)
if o.analyzed:
o.analyzed.accept(self)

Expand Down
8 changes: 8 additions & 0 deletionstest-data/unit/check-python38.test
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -573,6 +573,14 @@ def foo() -> None:
[x := x + y for y in [1, 2, 3]]
[builtins fixtures/dict.pyi]

[case testWalrusUsedBeforeDef]
# flags: --python-version 3.8
class C:
def f(self, c: 'C') -> None: pass

(x := C()).f(y) # E: Cannot determine type of "y" # E: Name "y" is used before definition
(y := C()).f(y)

[case testOverloadWithPositionalOnlySelf]
# flags: --python-version 3.8
from typing import overload, Optional
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp