From 60939b00afede13feeec3cee6f6dfe6eb2df1593 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 4 Apr 2023 13:44:58 +0100 Subject: [PATCH] Various improvements to non-generated `protobuf` stubs (#10010) --- .../protobuf/internal/well_known_types.pyi | 20 +++++----- .../protobuf/google/protobuf/text_format.pyi | 40 +++++++++---------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi index f0e17309d..e257cf052 100644 --- a/stubs/protobuf/google/protobuf/internal/well_known_types.pyi +++ b/stubs/protobuf/google/protobuf/internal/well_known_types.pyi @@ -7,17 +7,19 @@ from typing_extensions import TypeAlias from google.protobuf import struct_pb2 class Any: - type_url: tAny = ... - value: tAny = ... - def Pack(self, msg: tAny, type_url_prefix: str = ..., deterministic: Incomplete | None = ...) -> None: ... - def Unpack(self, msg: tAny) -> bool: ... + type_url: str + value: Incomplete + def Pack( + self, msg: Incomplete, type_url_prefix: str = "type.googleapis.com/", deterministic: Incomplete | None = None + ) -> None: ... + def Unpack(self, msg: Incomplete) -> bool: ... def TypeName(self) -> str: ... - def Is(self, descriptor: tAny) -> bool: ... + def Is(self, descriptor: Incomplete) -> bool: ... class Timestamp: def ToJsonString(self) -> str: ... - seconds: int = ... - nanos: int = ... + seconds: int + nanos: int def FromJsonString(self, value: str) -> None: ... def GetCurrentTime(self) -> None: ... def ToNanoseconds(self) -> int: ... @@ -33,8 +35,8 @@ class Timestamp: class Duration: def ToJsonString(self) -> str: ... - seconds: int = ... - nanos: int = ... + seconds: int + nanos: int def FromJsonString(self, value: tAny) -> None: ... def ToNanoseconds(self) -> int: ... def ToMicroseconds(self) -> int: ... diff --git a/stubs/protobuf/google/protobuf/text_format.pyi b/stubs/protobuf/google/protobuf/text_format.pyi index 3cd245913..593739c94 100644 --- a/stubs/protobuf/google/protobuf/text_format.pyi +++ b/stubs/protobuf/google/protobuf/text_format.pyi @@ -107,20 +107,20 @@ def PrintFieldValue( ) -> None: ... class _Printer: - out: SupportsWrite[str] = ... - indent: int = ... - as_utf8: bool = ... - as_one_line: bool = ... - use_short_repeated_primitives: bool = ... - pointy_brackets: bool = ... - use_index_order: bool = ... - float_format: str | None = ... - double_format: str | None = ... - use_field_number: bool = ... - descriptor_pool: DescriptorPool | None = ... - message_formatter: _MessageFormatter | None = ... - print_unknown_fields: bool = ... - force_colon: bool = ... + out: SupportsWrite[str] + indent: int + as_utf8: bool + as_one_line: bool + use_short_repeated_primitives: bool + pointy_brackets: bool + use_index_order: bool + float_format: str | None + double_format: str | None + use_field_number: bool + descriptor_pool: DescriptorPool | None + message_formatter: _MessageFormatter | None + print_unknown_fields: bool + force_colon: bool def __init__( self, out: SupportsWrite[str], @@ -168,10 +168,10 @@ def MergeLines( ) -> _M: ... class _Parser: - allow_unknown_extension: bool = ... - allow_field_number: bool = ... - descriptor_pool: DescriptorPool | None = ... - allow_unknown_field: bool = ... + allow_unknown_extension: bool + allow_field_number: bool + descriptor_pool: DescriptorPool | None + allow_unknown_field: bool def __init__( self, allow_unknown_extension: bool = ..., @@ -185,8 +185,8 @@ class _Parser: _ParseError: TypeAlias = ParseError class Tokenizer: - token: str = ... - def __init__(self, lines: Iterable[str], skip_comments: bool = ...) -> None: ... + token: str + def __init__(self, lines: Iterable[str], skip_comments: bool = True) -> None: ... def LookingAt(self, token: str) -> bool: ... def AtEnd(self) -> bool: ... def TryConsume(self, token: str) -> bool: ...