Skip to content
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

Improving "FA100 / future-rewritable-type-annotation" message #10573

Closed
Avasam opened this issue Mar 25, 2024 · 1 comment · Fixed by #11381
Closed

Improving "FA100 / future-rewritable-type-annotation" message #10573

Avasam opened this issue Mar 25, 2024 · 1 comment · Fixed by #11381
Labels
help wanted Contributions especially welcome rule Implementing or modifying a lint rule

Comments

@Avasam
Copy link

Avasam commented Mar 25, 2024

The message for rule https://docs.astral.sh/ruff/rules/future-rewritable-type-annotation/ Missing from __future__ import annotations, but uses {name} is slightly confusing / misleading. It sounds like I need to use from __future__ import annotations when using typing.Union, when it actually means that adding from __future__ import annotations can lead to simplified /modernized syntax. But that's also not checked unless relevant pyupgrades rules are turned on.

I think the message could be tweaked a bit to reflect that. I also assume FA and UP rules will likely be grouped together after the rules categorization #1774

@AlexWaygood AlexWaygood added the rule Implementing or modifying a lint rule label Mar 25, 2024
@MichaReiser MichaReiser added the help wanted Contributions especially welcome label Mar 26, 2024
@Olegt0rr
Copy link

Olegt0rr commented Apr 11, 2024

The same issue.
FA100 false positive detection

python 3.9
target-version = "py39"

from typing import Optional

from aiohttp import ClientSession

class Client:
    def __init__(self) -> None:
        self._session: Optional[ClientSession] = None

Optional is highlighted with

FA100 Missing `from __future__ import annotations`, but uses `typing.Optional`

charliermarsh pushed a commit that referenced this issue May 13, 2024
## 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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions especially welcome rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants