-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Allow unicode and bytes in EnumTypeWrapper.Value #5743
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
Intended to do this in python#5004, but missed for python2
I think the two failing checks are not related to my change? I read through them and the appeared not related. |
I fixed the stubtest issue in #5742 too. If you want you can copy over the fix from that PR. |
@@ -10,7 +10,7 @@ class _EnumTypeWrapper(Generic[_V]): | |||
DESCRIPTOR: EnumDescriptor | |||
def __init__(self, enum_type: EnumDescriptor) -> None: ... | |||
def Name(self, number: _V) -> str: ... | |||
def Value(self, name: Union[str, bytes]) -> _V: ... | |||
def Value(self, name: Union[Text, bytes]) -> _V: ... |
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.
Nit (not a blocker): We now prefer PEP 604 syntax:
def Value(self, name: Union[Text, bytes]) -> _V: ... | |
def Value(self, name: Text | bytes) -> _V: ... |
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 decided to apply this before merge, because why not.
Co-authored-by: Sebastian Rittau <[email protected]>
@@ -1,4 +1,4 @@ | |||
from typing import Generic, List, Tuple, TypeVar, Union | |||
from typing import Generic, List, Text, Tuple, TypeVar, Union |
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.
And now we need to change the import too:
from typing import Generic, List, Text, Tuple, TypeVar, Union | |
from typing import Generic, List, Text, Tuple, TypeVar |
Intended to do this in #5004, but missed for python2