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

F401 removes import required by typing annotations #6038

Closed
thomas-moulard opened this issue Jul 24, 2023 · 1 comment
Closed

F401 removes import required by typing annotations #6038

thomas-moulard opened this issue Jul 24, 2023 · 1 comment

Comments

@thomas-moulard
Copy link

F401 is a rule that removes unused imports.

The issue is that F401 removes imports that are necessary for typing annotations expressed as comments, see below.

Repro Case

from typing import Any  # <-- this import is removed by ruff
x = 1  # type: Any

Current Behavior

The import is eliminated erroneously:

x = 1  # type: Any

Desired Behavior

The code is unchanged.

from typing import Any  # <-- this import is removed by ruff
x = 1  # type: Any
@charliermarsh
Copy link
Member

I believe this is a duplicate of #1619 (Ruff doesn't parse comment annotations right now).

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants