# noqa
from our codebase.github.com/PyCQA/pyflakes/pull…
Fix false positive with partially quoted annotations
What would happen was that we would have code like:
if TYPE_CHECKING:
from app.resources.blah import Blah
@dataclass
class Thing
blah: Optional["Blah"]
And flake8/pyflakes would complain F401 for unused import, as it didn't realize that Blah was used in the type declaration. With
"Blah"
it would work, in the cases where you don't use e.g. List[]
, Optional[]
or Union[]
, and with "Optional[Blah]"
it would work too, but I only knew the quote-all-the-things workaround today, on the same day I found the real fix.Fewer noqa good.
#python #pyflakes #flake8