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 when type used in annotation #129

Closed
samuelcolvin opened this issue Sep 8, 2022 · 2 comments
Closed

F401 when type used in annotation #129

samuelcolvin opened this issue Sep 8, 2022 · 2 comments

Comments

@samuelcolvin
Copy link

Kind of the opposite to #128.

E.g. NamedTuple is imported here, and used here.

But shows up in errors:

pydantic/annotated_types.py:2:1: F401 `typing.NamedTuple` imported but unused

There are currently 30 of these errors from running ruff on pydantic.

As with #128, I've build ruff from main (a8f4faa).

@gempir
Copy link

gempir commented Sep 8, 2023

Is this actually fixed?

I use a type annotation here:

for product_certificate in qa_product.product_certificates:  # type: ProductCertificate

And ruff just removes my import for ProductCertificate
I need to specific # noqa: F401 on the import line to avoid it.

@charliermarsh
Copy link
Member

@gempir - I believe the issue in that case is that Ruff does not parse type comments. See: #1619

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

3 participants