-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Visit PEP 764 inline
TypedDict
s' keys as non-type-expressions (#15073)
## Summary Resolves #10812. ## Test Plan `cargo nextest run` and `cargo insta test`.
- Loading branch information
1 parent
8a98d88
commit d4ee6ab
Showing
6 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
crates/ruff_linter/resources/test/fixtures/pyflakes/F821_30.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Regression tests for: | ||
# https://github.com/astral-sh/ruff/issues/10812 | ||
|
||
from typing import Annotated, Literal, TypedDict | ||
|
||
|
||
# No errors | ||
single: TypedDict[{"foo": int}] | ||
|
||
# Error at `qux` | ||
multiple: TypedDict[{ | ||
"bar": str, | ||
"baz": list["qux"], | ||
}] | ||
|
||
# Error at `dolor` | ||
nested: TypedDict[ | ||
"lorem": TypedDict[{ | ||
"ipsum": "dolor" | ||
}], | ||
"sit": Literal["amet"] | ||
] | ||
|
||
# Error at `adipiscing`, `eiusmod`, `tempor` | ||
unpack: TypedDict[{ | ||
"consectetur": Annotated["adipiscing", "elit"] | ||
**{"sed do": str, int: "eiusmod", **tempor} | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...er/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_30.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
snapshot_kind: text | ||
--- | ||
F821_30.py:13:18: F821 Undefined name `qux` | ||
| | ||
11 | multiple: TypedDict[{ | ||
12 | "bar": str, | ||
13 | "baz": list["qux"], | ||
| ^^^ F821 | ||
14 | }] | ||
| | ||
|
||
F821_30.py:19:19: F821 Undefined name `dolor` | ||
| | ||
17 | nested: TypedDict[ | ||
18 | "lorem": TypedDict[{ | ||
19 | "ipsum": "dolor" | ||
| ^^^^^ F821 | ||
20 | }], | ||
21 | "sit": Literal["amet"] | ||
| | ||
|
||
F821_30.py:26:31: F821 Undefined name `adipiscing` | ||
| | ||
24 | # Error at `adipiscing`, `eiusmod`, `tempor` | ||
25 | unpack: TypedDict[{ | ||
26 | "consectetur": Annotated["adipiscing", "elit"] | ||
| ^^^^^^^^^^ F821 | ||
27 | **{"sed do": str, int: "eiusmod", **tempor} | ||
28 | }] | ||
| | ||
|
||
F821_30.py:27:29: F821 Undefined name `eiusmod` | ||
| | ||
25 | unpack: TypedDict[{ | ||
26 | "consectetur": Annotated["adipiscing", "elit"] | ||
27 | **{"sed do": str, int: "eiusmod", **tempor} | ||
| ^^^^^^^ F821 | ||
28 | }] | ||
| | ||
|
||
F821_30.py:27:41: F821 Undefined name `tempor` | ||
| | ||
25 | unpack: TypedDict[{ | ||
26 | "consectetur": Annotated["adipiscing", "elit"] | ||
27 | **{"sed do": str, int: "eiusmod", **tempor} | ||
| ^^^^^^ F821 | ||
28 | }] | ||
| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters