snok / flake8-type-checking

Flake8 plugin for managing type-checking imports & forward references.
BSD 3-Clause "New" or "Revised" License
113 stars 16 forks source link

Fix: extract names from ForwardRef #171

Closed Daverball closed 1 year ago

Daverball commented 1 year ago

This is a draft because it's based on #170 due to some of the refactors and may yet need to change a bit more and thus should not be merged until #170 is merged.

This extracts all the names from the wrapped annotations and stores them in a set alongside the annotation, this is a little bit more reliable than the substring check we have been doing thus far and also works more reliably for determining when F401 should be sufficient for unused_imports.

sondrelg commented 1 year ago

Ah, nice. I actually wouldn't mind if you combined this with #170 :+1:

Daverball commented 1 year ago

Ah, nice. I actually wouldn't mind if you combined this with #170 👍

That works for me, I'll close this and merge this into the branch.