mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:21 +00:00
Reword future-rewritable-type-annotation
(FA100
) message (#11381)
## Summary Changes `future-rewritable-type-annotation` (`FA100`) message to be less confusing. Uses phrasing from the rule documentation to be consistent. For example, ``` from_typing_import.py:5:13: FA100 Add `from __future__ import annotations` to rewrite `typing.List` more succinctly ``` Closes #10573. ## Test Plan `cargo nextest run`
This commit is contained in:
parent
bc7856e899
commit
5ab4cc86c2
6 changed files with 8 additions and 18 deletions
|
@ -72,7 +72,7 @@ impl Violation for FutureRewritableTypeAnnotation {
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
let FutureRewritableTypeAnnotation { name } = self;
|
let FutureRewritableTypeAnnotation { name } = self;
|
||||||
format!("Missing `from __future__ import annotations`, but uses `{name}`")
|
format!("Add `from __future__ import annotations` to simplify `{name}`")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
||||||
---
|
---
|
||||||
edge_case.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
|
edge_case.py:5:13: FA100 Add `from __future__ import annotations` to simplify `typing.List`
|
||||||
|
|
|
|
||||||
5 | def main(_: List[int]) -> None:
|
5 | def main(_: List[int]) -> None:
|
||||||
| ^^^^ FA100
|
| ^^^^ FA100
|
||||||
|
@ -9,12 +9,10 @@ edge_case.py:5:13: FA100 Missing `from __future__ import annotations`, but uses
|
||||||
7 | a_list.append("hello")
|
7 | a_list.append("hello")
|
||||||
|
|
|
|
||||||
|
|
||||||
edge_case.py:6:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
|
edge_case.py:6:13: FA100 Add `from __future__ import annotations` to simplify `typing.List`
|
||||||
|
|
|
|
||||||
5 | def main(_: List[int]) -> None:
|
5 | def main(_: List[int]) -> None:
|
||||||
6 | a_list: t.List[str] = []
|
6 | a_list: t.List[str] = []
|
||||||
| ^^^^^^ FA100
|
| ^^^^^^ FA100
|
||||||
7 | a_list.append("hello")
|
7 | a_list.append("hello")
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
||||||
---
|
---
|
||||||
from_typing_import.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
|
from_typing_import.py:5:13: FA100 Add `from __future__ import annotations` to simplify `typing.List`
|
||||||
|
|
|
|
||||||
4 | def main() -> None:
|
4 | def main() -> None:
|
||||||
5 | a_list: List[str] = []
|
5 | a_list: List[str] = []
|
||||||
| ^^^^ FA100
|
| ^^^^ FA100
|
||||||
6 | a_list.append("hello")
|
6 | a_list.append("hello")
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
||||||
---
|
---
|
||||||
from_typing_import_many.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
|
from_typing_import_many.py:5:13: FA100 Add `from __future__ import annotations` to simplify `typing.List`
|
||||||
|
|
|
|
||||||
4 | def main() -> None:
|
4 | def main() -> None:
|
||||||
5 | a_list: List[Optional[str]] = []
|
5 | a_list: List[Optional[str]] = []
|
||||||
|
@ -10,7 +10,7 @@ from_typing_import_many.py:5:13: FA100 Missing `from __future__ import annotatio
|
||||||
7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {})
|
7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {})
|
||||||
|
|
|
|
||||||
|
|
||||||
from_typing_import_many.py:5:18: FA100 Missing `from __future__ import annotations`, but uses `typing.Optional`
|
from_typing_import_many.py:5:18: FA100 Add `from __future__ import annotations` to simplify `typing.Optional`
|
||||||
|
|
|
|
||||||
4 | def main() -> None:
|
4 | def main() -> None:
|
||||||
5 | a_list: List[Optional[str]] = []
|
5 | a_list: List[Optional[str]] = []
|
||||||
|
@ -18,5 +18,3 @@ from_typing_import_many.py:5:18: FA100 Missing `from __future__ import annotatio
|
||||||
6 | a_list.append("hello")
|
6 | a_list.append("hello")
|
||||||
7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {})
|
7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {})
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
||||||
---
|
---
|
||||||
import_typing.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
|
import_typing.py:5:13: FA100 Add `from __future__ import annotations` to simplify `typing.List`
|
||||||
|
|
|
|
||||||
4 | def main() -> None:
|
4 | def main() -> None:
|
||||||
5 | a_list: typing.List[str] = []
|
5 | a_list: typing.List[str] = []
|
||||||
| ^^^^^^^^^^^ FA100
|
| ^^^^^^^^^^^ FA100
|
||||||
6 | a_list.append("hello")
|
6 | a_list.append("hello")
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs
|
||||||
---
|
---
|
||||||
import_typing_as.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
|
import_typing_as.py:5:13: FA100 Add `from __future__ import annotations` to simplify `typing.List`
|
||||||
|
|
|
|
||||||
4 | def main() -> None:
|
4 | def main() -> None:
|
||||||
5 | a_list: t.List[str] = []
|
5 | a_list: t.List[str] = []
|
||||||
| ^^^^^^ FA100
|
| ^^^^^^ FA100
|
||||||
6 | a_list.append("hello")
|
6 | a_list.append("hello")
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue