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

Allow unicode and bytes in EnumTypeWrapper.Value #5743

Merged
merged 4 commits into from Jul 9, 2021

Conversation

nipunn1313
Copy link
Contributor

Intended to do this in #5004, but missed for python2

Intended to do this in python#5004, but missed for python2
@nipunn1313
Copy link
Contributor Author

I think the two failing checks are not related to my change? I read through them and the appeared not related.

@JelleZijlstra
Copy link
Member

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: ...
Copy link
Collaborator

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:

Suggested change
def Value(self, name: Union[Text, bytes]) -> _V: ...
def Value(self, name: Text | bytes) -> _V: ...

Copy link
Collaborator

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 <srittau@rittau.biz>
@@ -1,4 +1,4 @@
from typing import Generic, List, Tuple, TypeVar, Union
from typing import Generic, List, Text, Tuple, TypeVar, Union
Copy link
Collaborator

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:

Suggested change
from typing import Generic, List, Text, Tuple, TypeVar, Union
from typing import Generic, List, Text, Tuple, TypeVar

@srittau srittau merged commit c5dd23a into python:master Jul 9, 2021
@nipunn1313 nipunn1313 deleted the protobuf_enum branch July 10, 2021 23:28
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.

None yet

4 participants