mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-08-01 21:50:21 +08:00
Mark stub-only private symbols as @type_check_only in third-party stubs (#14545)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
|
||||
from typing import Any, Protocol, SupportsIndex, TypeVar, overload
|
||||
from typing import Any, Protocol, SupportsIndex, TypeVar, overload, type_check_only
|
||||
from typing_extensions import Self
|
||||
|
||||
from google.protobuf.descriptor import Descriptor
|
||||
@@ -12,6 +12,7 @@ _K = TypeVar("_K", bound=bool | int | str)
|
||||
_ScalarV = TypeVar("_ScalarV", bound=bool | int | float | str | bytes)
|
||||
_MessageV = TypeVar("_MessageV", bound=Message)
|
||||
|
||||
@type_check_only
|
||||
class _ValueChecker(Protocol[_T]):
|
||||
def CheckValue(self, proposed_value: _T) -> _T: ...
|
||||
def DefaultValue(self) -> _T: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Generic, TypeVar
|
||||
from typing import Generic, TypeVar, type_check_only
|
||||
|
||||
from google.protobuf.descriptor import EnumDescriptor
|
||||
|
||||
@@ -9,6 +9,7 @@ _V = TypeVar("_V", bound=int)
|
||||
# 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...
|
||||
@type_check_only
|
||||
class _EnumTypeWrapper(type, Generic[_V]):
|
||||
DESCRIPTOR: EnumDescriptor
|
||||
def __init__(self, enum_type: EnumDescriptor) -> None: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from collections.abc import Iterator
|
||||
from typing import Any, Generic, TypeVar
|
||||
from typing import Any, Generic, TypeVar, type_check_only
|
||||
|
||||
from google.protobuf.descriptor import FieldDescriptor
|
||||
from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer
|
||||
@@ -11,6 +11,7 @@ _ExtenderMessageT = TypeVar(
|
||||
bound=Message | RepeatedScalarFieldContainer[Any] | RepeatedCompositeFieldContainer[Any] | bool | float | str | bytes,
|
||||
)
|
||||
|
||||
@type_check_only
|
||||
class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _ExtenderMessageT]): ...
|
||||
|
||||
class _ExtensionDict(Generic[_ContainerMessageT]):
|
||||
|
||||
@@ -59,15 +59,6 @@ class FieldMask:
|
||||
self, source: tAny, destination: tAny, replace_message_field: bool = False, replace_repeated_field: bool = False
|
||||
) -> None: ...
|
||||
|
||||
class _FieldMaskTree:
|
||||
def __init__(self, field_mask: Incomplete | None = ...) -> None: ...
|
||||
def MergeFromFieldMask(self, field_mask: tAny) -> None: ...
|
||||
def AddPath(self, path: tAny): ...
|
||||
def ToFieldMask(self, field_mask: tAny) -> None: ...
|
||||
def IntersectPath(self, path: tAny, intersection: tAny): ...
|
||||
def AddLeafNodes(self, prefix: tAny, node: tAny) -> None: ...
|
||||
def MergeMessage(self, source: tAny, destination: tAny, replace_message: tAny, replace_repeated: tAny) -> None: ...
|
||||
|
||||
_StructValue: TypeAlias = struct_pb2.Struct | struct_pb2.ListValue | str | float | bool | None
|
||||
_StructValueArg: TypeAlias = _StructValue | Mapping[str, _StructValueArg] | Sequence[_StructValueArg]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user