-
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).
- https://playknot.ruff.rs/a4955e44-b332-43c1-afc1-2063e4d6fc70
- https://mypy-play.net/?mypy=latest&python=3.9&gist=3077724b9d32730ed4970d8feda7f3bc
- https://pyright-play.net/?pythonVersion=3.9&code=JYWwDg9gTgLgBAZwJ4IFCuAM0SgdANwFMoFgIA7AfWHMwjgD4BeOACgGYAaOARh4EoAXKjii4mKBBBwYSMDQDmcUJFhwAyoQA2mVEA
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtyMulti-file analysis & type inferenceMulti-file analysis & type inference