mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
Use _typeshed.Self in protobuf/google/protobuf/message.pyi (#6955)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Sequence, TypeVar
|
||||
|
||||
from .descriptor import Descriptor, FieldDescriptor
|
||||
@@ -14,8 +15,8 @@ class Message:
|
||||
def __deepcopy__(self, memo=...): ...
|
||||
def __eq__(self, other_msg): ...
|
||||
def __ne__(self, other_msg): ...
|
||||
def MergeFrom(self: _M, other_msg: _M) -> None: ...
|
||||
def CopyFrom(self: _M, other_msg: _M) -> None: ...
|
||||
def MergeFrom(self: Self, other_msg: Self) -> None: ...
|
||||
def CopyFrom(self: Self, other_msg: Self) -> None: ...
|
||||
def Clear(self) -> None: ...
|
||||
def SetInParent(self) -> None: ...
|
||||
def IsInitialized(self) -> bool: ...
|
||||
@@ -24,11 +25,13 @@ class Message:
|
||||
def SerializeToString(self, deterministic: bool = ...) -> bytes: ...
|
||||
def SerializePartialToString(self, deterministic: bool = ...) -> bytes: ...
|
||||
def ListFields(self) -> Sequence[tuple[FieldDescriptor, Any]]: ...
|
||||
# The TypeVar must be bound to `Message` or we get mypy errors, so we cannot use `Self` for `HasExtension` & `ClearExtension`
|
||||
def HasExtension(self: _M, extension_handle: _ExtensionFieldDescriptor[_M, Any]) -> bool: ...
|
||||
def ClearExtension(self: _M, extension_handle: _ExtensionFieldDescriptor[_M, Any]) -> None: ...
|
||||
def ByteSize(self) -> int: ...
|
||||
@classmethod
|
||||
def FromString(cls: type[_M], s: bytes) -> _M: ...
|
||||
def FromString(cls: type[Self], s: bytes) -> Self: ...
|
||||
# The TypeVar must be bound to `Message` or we get mypy errors, so we cannot use `Self` for `Extensions`
|
||||
@property
|
||||
def Extensions(self: _M) -> _ExtensionDict[_M]: ...
|
||||
# Intentionally left out typing on these three methods, because they are
|
||||
|
||||
Reference in New Issue
Block a user