Pretend _EnumTypeWrapper inherits from type (#10203)

Pretend `google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper` inherits from `type`. It doesn't really, but this makes type checkers stop complaining when you use it as a metaclass, which is the only reason the class exists.
This commit is contained in:
Koichi Akabe
2023-07-22 23:50:40 +09:00
committed by GitHub
parent f577c4c133
commit 53a8932797

View File

@@ -6,7 +6,10 @@ _V = TypeVar("_V", bound=int)
# Expose a generic version so that those using mypy-protobuf
# can get autogenerated NewType wrapper around the int values
class _EnumTypeWrapper(Generic[_V]):
# NOTE: this doesn't actually inherit from type,
# but mypy doesn't support metaclasses that don't inherit from type,
# so we pretend it does in the stubs...
class _EnumTypeWrapper(type, Generic[_V]):
DESCRIPTOR: EnumDescriptor
def __init__(self, enum_type: EnumDescriptor) -> None: ...
def Name(self, number: _V) -> str: ...