From 53a893279713c8abcc970a578d6f28e97efdd68f Mon Sep 17 00:00:00 2001 From: Koichi Akabe Date: Sat, 22 Jul 2023 23:50:40 +0900 Subject: [PATCH] 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. --- .../protobuf/google/protobuf/internal/enum_type_wrapper.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi b/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi index 18da7c230..95b5b4bb2 100644 --- a/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi +++ b/stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi @@ -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: ...