8000 Fix internal error on list/dict comprehension with walrus operator in global scope by dhood · Pull Request #9062 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Fix internal error on list/dict comprehension with walrus operator in global scope #9062

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
Changes from 1 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
Prev Previous commit
Next Next commit
Duplicate walrus dict/list tests to global scope (passing)
  • Loading branch information
dhood committed Jun 28, 2020
commit c0f633f655e497938e16a3776ae44bdb6a9947c0
13 changes: 13 additions & 0 deletions test-data/unit/check-python38.test
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ if a := 2:
while b := "x":
reveal_type(b) # N: Revealed type is 'builtins.str'

l = [y2 := 1, y2 + 2, y2 + 3]
reveal_type(y2) # N: Revealed type is 'builtins.int'
reveal_type(l) # N: Revealed type is 'builtins.list[builtins.int*]'

d = {'a': (a2 := 1), 'b': a2 + 1, 'c': a2 + 2}
reveal_type(d) # N: Revealed type is 'builtins.dict[builtins.str*, builtins.int*]'
reveal_type(a2) # N: Revealed type is 'builtins.int'

d2 = {(prefix := 'key_') + 'a': (start_val := 1), prefix + 'b': start_val + 1, prefix + 'c': start_val + 2}
reveal_type(d2) # N: Revealed type is 'builtins.dict[builtins.str*, builtins.int*]'
reveal_type(prefix) # N: Revealed type is 'builtins.str'
reveal_type(start_val) # N: Revealed type is 'builtins.int'

def f(x: int = (c := 4)) -> int:
if a := 2:
reveal_type(a) # N: Revealed type is 'builtins.int'
Expand Down
0