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

Use short type var names per PEP 8 #4553

Closed
wants to merge 1 commit into from

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Sep 17, 2020

Closes: #1872

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally like the T suffix (#1872 (comment)), but whatever :-)

@@ -55,7 +55,7 @@ class IntParamType(ParamType):
class IntRange(IntParamType):
def __init__(self, min: Optional[int] = ..., max: Optional[int] = ..., clamp: bool = ...) -> None: ...

_PathType = TypeVar("_PathType", str, bytes)
_PathType = Any
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_PathType = Any
_PathType = AnyStr

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_PathType is never used as a type variable, it's just a glorified Union[str, bytes] return type. (Which means I can leave my obligatory link to python/typing#566 here.)

@JelleZijlstra
Copy link
Member

This has a couple of merge conflicts now. I'm not sure I like this change; T is fine for a general-purpose typevar, but I find it clearer to use a more explicit name like MessageType for typevars with a bound.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Jan 4, 2021

It's also bad user experience in the cases where these types get mentioned in type checker error messages (happened recently where we had to rename _LT to _SupportsLessThanT in python/mypy#9582 / #4579).
I opened #4898 as an alternative for the type variables identified in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Follow PEP 8 recommendations for type variable names
3 participants