-
from __future__ import annotations
from enum import Enum
from packaging.version import Version
class Foo:
class Version(Enum):
pass
version: Version | None = None Inside Is this something that pyright could catch? I don't really understand why Edit: I think this is actually a bug. Pyflakes detects the unused import with/without |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Pyright is working correctly here. The |
Beta Was this translation helpful? Give feedback.
Pyright is working correctly here. The
from __future__ import annotations
directive tells the runtime to defer evaluation of type annotations. When the annotationVersion | None
is evaluated in a deferred manner, the importedVersion
is used. If you comment out thefrom __future__ import annotations
, the annotation is evaluated at runtime immediately when the runtime encounters that statement, and at that pointVersion
refers to the inner class of that name, and the imported symbol of that name is not referenced.