Skip to content

Shadowed unused import not detected when using from __future__ import annotations #9640

Closed Answered by erictraut
injust asked this question in Q&A
Discussion options

You must be logged in to vote

Pyright is working correctly here. The from __future__ import annotations directive tells the runtime to defer evaluation of type annotations. When the annotation Version | None is evaluated in a deferred manner, the imported Version is used. If you comment out the from __future__ import annotations, the annotation is evaluated at runtime immediately when the runtime encounters that statement, and at that point Version refers to the inner class of that name, and the imported symbol of that name is not referenced.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@injust
Comment options

Answer selected by injust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants