Skip to content

Commit ebcdcfa

Browse files
asyksJelleZijlstra
andauthored
Makes DESCRIPTOR non nullable again (#7125)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 51cdd2c commit ebcdcfa

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

stubs/protobuf/@tests/stubtest_allowlist.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
google.protobuf\..*_pb2\..*
44

55
google.protobuf.internal.containers.BaseContainer.sort
6+
# While Message and Descriptor are both defined with a null DESCRIPTOR,
7+
# subclasses of Message and instances of EnumTypeWrapper require this value to
8+
# be set, and since these type stubs are intended for use with protoc-generated
9+
# python it's more accurate to make them non-nullable.
10+
google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper.DESCRIPTOR
11+
google.protobuf.message.Message.DESCRIPTOR
612
google.protobuf.message.Message.SerializePartialToString
713
google.protobuf.message.Message.SerializeToString
814
google.protobuf.service.Service.GetDescriptor

stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _V = TypeVar("_V", bound=int)
77
# Expose a generic version so that those using mypy-protobuf
88
# can get autogenerated NewType wrapper around the int values
99
class _EnumTypeWrapper(Generic[_V]):
10-
DESCRIPTOR: EnumDescriptor | None
10+
DESCRIPTOR: EnumDescriptor
1111
def __init__(self, enum_type: EnumDescriptor) -> None: ...
1212
def Name(self, number: _V) -> str: ...
1313
def Value(self, name: Text | bytes) -> _V: ...

stubs/protobuf/google/protobuf/message.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class EncodeError(Error): ...
1111
_M = TypeVar("_M", bound=Message) # message type (of self)
1212

1313
class Message:
14-
DESCRIPTOR: Descriptor | None
14+
DESCRIPTOR: Descriptor
1515
def __deepcopy__(self, memo=...): ...
1616
def __eq__(self, other_msg): ...
1717
def __ne__(self, other_msg): ...

0 commit comments

Comments
 (0)