-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with solving value constrained type var in presence of Any #17952
Comments
Bisects to #17458 , probably caused by python/typeshed#12208 Note explicitly inheriting from |
Setuptools failure: pypa/setuptools#4688 & https://github.com/pypa/setuptools/actions/runs/11389961011/job/31690481419?pr=4688#step:9:68 |
Are you interested in picking up reverting that typeshed PR? |
Nevermind, after failing to replicate in a typeshed test, and further investigation, mine was an issue with a setuptools declaration that was revealed by mypy 1.12 if sys.version_info >= (3, 9):
StrPath: TypeAlias = Union[str, os.PathLike[str]] # Same as _typeshed.StrPath
else:
StrPath: TypeAlias = Union[str, os.PathLike] Changing to: if TYPE_CHECKING:
StrPath: TypeAlias = Union[str, os.PathLike[str]] # Same as _typeshed.StrPath
else:
# Python 3.8 support
StrPath: TypeAlias = Union[str, os.PathLike] Which explains why I was only seeing this on 3.8. |
For OP's issue and another related regression I found in setuptools: python/typeshed#12837 |
For the purposes of making further changes to mypy, here's a repro that's independent of abspath in typeshed:
|
Bug Report
In 1.11.0, classes that inherit from os.PathLike could be used with
os.path
methods. As of 3.12, these methods claim to accept "any object implementing the os.PathLike protocol". However, in 1.12.0, mypy emits an error.To Reproduce
Expected Behavior
Unless I'm missing something,
MyPath
should be valid to pass, no?Actual Behavior
Your Environment
mypy.ini
(and other config files): N/AThe text was updated successfully, but these errors were encountered: