-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
PathLike: change to Protocol #4447
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
Conversation
Hmm, discovered python/mypy#5775 |
Also, the stubtest windows tests aren't doing anything (and I think this has been the case for a while, probably since they were moved to Github Actions) |
class _PathLike(Generic[AnyStr]): | ||
def __fspath__(self) -> AnyStr: ... | ||
_AnyStr_co = TypeVar("_AnyStr_co", str, bytes, covariant=True) | ||
class _PathLike(Protocol[_AnyStr_co]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put this in _typeshed
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to... even if it can be made to work, it'll involve a mypy-typeshed dance (and maybe changes to other type checkers) for little benefit.
Plus _typeshed is for making types internally reusable, and PathLike is already internally (and externally) reusable from os
I made PathLike a protocol in python#4447, but it should also be runtime_checkable. Caught by mypy_primer: src/werkzeug/utils.py:646: error: Only @runtime_checkable protocols can be used with instance and class checks
I made PathLike a protocol in #4447, but it should also be runtime_checkable. Caught by mypy_primer: src/werkzeug/utils.py:646: error: Only @runtime_checkable protocols can be used with instance and class checks
No description provided.