Skip to content

Commit

Permalink
Reword future-rewritable-type-annotation (FA100) message (astral-…
Browse files Browse the repository at this point in the history
…sh#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 astral-sh#10573.

## Test Plan

`cargo nextest run`
  • Loading branch information
tjkuson authored May 13, 2024
1 parent bc7856e commit 5ab4cc8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Violation for FutureRewritableTypeAnnotation {
#[derive_message_formats]
fn message(&self) -> String {
let FutureRewritableTypeAnnotation { name } = self;
format!("Missing `from __future__ import annotations`, but uses `{name}`")
format!("Add `from __future__ import annotations` to simplify `{name}`")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
---
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:
| ^^^^ FA100
6 | a_list: t.List[str] = []
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:
6 | a_list: t.List[str] = []
| ^^^^^^ FA100
7 | a_list.append("hello")
|


Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
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:
5 | a_list: List[str] = []
| ^^^^ FA100
6 | a_list.append("hello")
|


Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
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:
5 | a_list: List[Optional[str]] = []
Expand All @@ -10,13 +10,11 @@ from_typing_import_many.py:5:13: FA100 Missing `from __future__ import annotatio
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:
5 | a_list: List[Optional[str]] = []
| ^^^^^^^^ FA100
6 | a_list.append("hello")
7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {})
|


Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
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:
5 | a_list: typing.List[str] = []
| ^^^^^^^^^^^ FA100
6 | a_list.append("hello")
|


Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
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:
5 | a_list: t.List[str] = []
| ^^^^^^ FA100
6 | a_list.append("hello")
|


0 comments on commit 5ab4cc8

Please sign in to comment.