Skip to content

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

Merged
merged 4 commits into from
Jul 9, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi
Original file line number Diff line number Diff line change
@@ -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


from google.protobuf.descriptor import EnumDescriptor

Expand All @@ -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.

def keys(self) -> List[str]: ...
def values(self) -> List[_V]: ...
def items(self) -> List[Tuple[str, _V]]: ...
Expand Down