-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed as not planned
Closed as not planned
Copy link
Labels
bugSomething isn't workingSomething isn't workingtyMulti-file analysis & type inferenceMulti-file analysis & type inference
Milestone
Description
Summary
If python-version is set to 3.9, red-knot emits an error on the following code:
import sys
if sys.version_info >= (3, 11):
from typing import Self # error: Module `typing` has no member `Self`Red-knot correctly understands that the code is okay if python-version is set to 3.11 or higher. However, this kind of sys.version_info-guarded import is reasonably common in code that aims to support old Python versions -- e.g. lots of libraries do things like this, so that they can have typing_extensions only as a dependency on old Python versions:
import sys
if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import SelfMypy and pyright both support this pattern, so I think it's quite important for red-knot to also support it (though it's perhaps not something that's essential to do before the alpha release).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtyMulti-file analysis & type inferenceMulti-file analysis & type inference