-
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.
Avoid flagging
__future__
annotations as required for non-evaluated…
… type annotations (#11414) ## Summary If an annotation won't be evaluated at runtime, we don't need to flag `from __future__ import annotations` as required. This applies both to quoted annotations and annotations outside of runtime-evaluated positions, like: ```python def main() -> None: a_list: list[str] | None = [] a_list.append("hello") ``` Closes #11397.
- Loading branch information
1 parent
7225732
commit 83b8b62
Showing
7 changed files
with
16 additions
and
111 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/ok_quoted_type.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,7 @@ | ||
def main() -> None: | ||
a_list: list[str] | None = [] | ||
a_list.append("hello") | ||
|
||
|
||
def hello(y: "dict[str, int] | None") -> None: | ||
del y |
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
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
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
4 changes: 4 additions & 0 deletions
4
...pshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_ok_quoted_type.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,4 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs | ||
--- | ||
|