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
pathlib.PurePath.__class_getitem__
does not return GenericAlias
#90641
Comments
After reviewing #30777 I had a chance to look through other definitions of All other definitions already have this form: I don't think that there's anything special about Initial PR: #17498 PR is on its way. |
Why __class_getitem__ was added in PurePath at first place? PurePath should not be a generic class, unlike to os.PathLike. For os.PathLike the type parameters represent the returning type of os.fspath() (either str or bytes), but the pathlib module only supports paths as strings, so no parametrization is needed. I think PurePath.__class_getitem__ should be removed. |
It looks like __class_getitem__ was added to PurePath at @asvetlov's request in PR 17498. But, I'm also not quite sure why. The class is not generic in typeshed, so type-checkers will raise an error if you do PurePath[str], even if it is possible to do so at runtime. Typeshed stub for PurePath: https://github.com/python/typeshed/blob/dff461fc6adef1ec3a4b58af5abdf0cdebf2429a/stdlib/pathlib.pyi#L20 |
IIRC it was added to reflect the presence of __class_getitem__ method in typeshed. |
This issue is not related to the parser, so I am unmarking it. |
It is not related to email and asyncio either. |
The desmper121 user appears to be a spammer; I am undoing all the changes they made to this BPO ticket. |
PurePath.__class_getitem__
to returnGenericAlias
#30822__class_getitem__
frompathlib.PurePath
#30848pathlib
classes from list of stdlib classes that can be parameterized at runtime #31281Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: