Skip to content
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

Rename _typeshed.AnyPath? #5470

Closed
srittau opened this issue May 16, 2021 · 5 comments
Closed

Rename _typeshed.AnyPath? #5470

srittau opened this issue May 16, 2021 · 5 comments
Labels
project: policy Organization of the typeshed project

Comments

@srittau
Copy link
Collaborator

srittau commented May 16, 2021

TLDR: Let's rename AnyPath to PathName (or a better alias).

I seem to remember that @JelleZijlstra didn't like the name AnyPath as an alias for str | bytes | PathLike[str] | PathLike[bytes] when I introduced it. I agreed, but couldn't come up with a better name. When working on #5467, it became apparent to me that having a "real" AnyPath, i.e. an alias that is basically AnyPath[_T] = _T | PathLike[_T] would be quite useful. I don't think there is a way to have a generic alias yet, but I still propose we should rename AnyPath in preparation and to avoid confusion with AnyStr. The best I can come up with at the moment is PathName. Any better ideas? Other suggestions? Not a good idea?

@srittau srittau added the project: policy Organization of the typeshed project label May 16, 2021
@Akuli
Copy link
Collaborator

Akuli commented May 16, 2021

Tkinter stubs have a generic alias:

_TkinterSequence = Union[List[_T], Tuple[_T, ...]]

@JelleZijlstra
Copy link
Member

If only we could rename AnyStr. It would be better if typevars were suffixed with T.

Tkinter stubs have a generic alias

I think mypy has issues with aliases of the form T | Cls[T]. Worth trying again though to see if that works now. In a couple of places we have added separate overloads for AnyStr and PathLike to work around that bug.

I'm not having much luck thinking of a better name that's still concise. PathOfAnyKind, StrOrBytesPath?

@srittau
Copy link
Collaborator Author

srittau commented May 16, 2021

Maybe StrOrBytesPath is the best option. While not concise, it's clear, especially its relation to StrPath and BytesPath.

srittau added a commit to srittau/typeshed that referenced this issue May 17, 2021
* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs.
* Add StrOrBytesPath as preferred alias for AnyPath.
* Replace all remaining AnyPath instances with StrOrBytesPath.
* Mark AnyPath as obsolete.

Part of python#5470
srittau added a commit that referenced this issue May 17, 2021
* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs.
* Add StrOrBytesPath as preferred alias for AnyPath.
* Replace all remaining AnyPath instances with StrOrBytesPath.
* Mark AnyPath as obsolete.

Part of #5470
srittau added a commit to srittau/typeshed that referenced this issue Jun 8, 2021
@srittau srittau mentioned this issue Jun 8, 2021
@srittau
Copy link
Collaborator Author

srittau commented Jun 8, 2021

#5592 removes AnyPath. I'd suggest to give it a few months (and at least a mypy release) before introducing the AnyPath generic alias.

srittau added a commit that referenced this issue Jun 8, 2021
@AlexWaygood
Copy link
Member

AlexWaygood commented Jun 12, 2022

The original AnyPath has now been renamed, and we have a generic type alias in the form of _typeshed.GenericPath: #7970. Closing this issue as completed 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: policy Organization of the typeshed project
Projects
None yet
Development

No branches or pull requests

4 participants