Skip to content

Commit ac30b96

Browse files
authored
Use str instead of Text (#7812)
1 parent 5c13f8b commit ac30b96

File tree

7 files changed

+22
-23
lines changed

7 files changed

+22
-23
lines changed

stdlib/typing_extensions.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import abc
22
import sys
33
from _typeshed import Self as TypeshedSelf # see #6932 for why the alias cannot have a leading underscore
4-
from typing import ( # noqa: Y022,Y027
4+
from typing import ( # noqa: Y022,Y027,Y039
55
TYPE_CHECKING as TYPE_CHECKING,
66
Any,
77
AsyncContextManager as AsyncContextManager,

stubs/protobuf/google/protobuf/internal/containers.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
2-
from typing import Any, Text, TypeVar, overload
2+
from typing import Any, TypeVar, overload
33
from typing_extensions import SupportsIndex
44

55
from google.protobuf.descriptor import Descriptor
@@ -9,8 +9,8 @@ from google.protobuf.internal.type_checkers import _ValueChecker
99
from google.protobuf.message import Message
1010

1111
_T = TypeVar("_T")
12-
_K = TypeVar("_K", bound=bool | int | Text)
13-
_ScalarV = TypeVar("_ScalarV", bound=bool | int | float | Text | bytes)
12+
_K = TypeVar("_K", bound=bool | int | str)
13+
_ScalarV = TypeVar("_ScalarV", bound=bool | int | float | str | bytes)
1414
_MessageV = TypeVar("_MessageV", bound=Message)
1515
_M = TypeVar("_M")
1616

stubs/protobuf/google/protobuf/internal/enum_type_wrapper.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Generic, Text, TypeVar
1+
from typing import Generic, TypeVar
22

33
from google.protobuf.descriptor import EnumDescriptor
44

@@ -10,7 +10,7 @@ class _EnumTypeWrapper(Generic[_V]):
1010
DESCRIPTOR: EnumDescriptor
1111
def __init__(self, enum_type: EnumDescriptor) -> None: ...
1212
def Name(self, number: _V) -> str: ...
13-
def Value(self, name: Text | bytes) -> _V: ...
13+
def Value(self, name: str | bytes) -> _V: ...
1414
def keys(self) -> list[str]: ...
1515
def values(self) -> list[_V]: ...
1616
def items(self) -> list[tuple[str, _V]]: ...

stubs/protobuf/google/protobuf/internal/extension_dict.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Iterator
2-
from typing import Any, Generic, Text, TypeVar
2+
from typing import Any, Generic, TypeVar
33

44
from google.protobuf.descriptor import FieldDescriptor
55
from google.protobuf.internal.containers import RepeatedCompositeFieldContainer, RepeatedScalarFieldContainer
@@ -8,7 +8,7 @@ from google.protobuf.message import Message
88
_ContainerMessageT = TypeVar("_ContainerMessageT", bound=Message)
99
_ExtenderMessageT = TypeVar(
1010
"_ExtenderMessageT",
11-
bound=Message | RepeatedScalarFieldContainer[Any] | RepeatedCompositeFieldContainer[Any] | bool | int | float | Text | bytes,
11+
bound=Message | RepeatedScalarFieldContainer[Any] | RepeatedCompositeFieldContainer[Any] | bool | int | float | str | bytes,
1212
)
1313

1414
class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _ExtenderMessageT]): ...

stubs/protobuf/google/protobuf/json_format.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Text, TypeVar
1+
from typing import Any, TypeVar
22

33
from google.protobuf.descriptor_pool import DescriptorPool
44
from google.protobuf.message import Message
@@ -26,9 +26,9 @@ def MessageToDict(
2626
use_integers_for_enums: bool = ...,
2727
descriptor_pool: DescriptorPool | None = ...,
2828
float_precision: int | None = ...,
29-
) -> dict[Text, Any]: ...
29+
) -> dict[str, Any]: ...
3030
def Parse(
31-
text: bytes | Text, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: DescriptorPool | None = ...
31+
text: bytes | str, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: DescriptorPool | None = ...
3232
) -> _MessageT: ...
3333
def ParseDict(
3434
js_dict: Any, message: _MessageT, ignore_unknown_fields: bool = ..., descriptor_pool: DescriptorPool | None = ...

stubs/protobuf/google/protobuf/service.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections.abc import Callable
22
from concurrent.futures import Future
3-
from typing import Text
43

54
from google.protobuf.descriptor import MethodDescriptor, ServiceDescriptor
65
from google.protobuf.message import Message
@@ -23,9 +22,9 @@ class Service:
2322
class RpcController:
2423
def Reset(self) -> None: ...
2524
def Failed(self) -> bool: ...
26-
def ErrorText(self) -> Text | None: ...
25+
def ErrorText(self) -> str | None: ...
2726
def StartCancel(self) -> None: ...
28-
def SetFailed(self, reason: Text) -> None: ...
27+
def SetFailed(self, reason: str) -> None: ...
2928
def IsCanceled(self) -> bool: ...
3029
def NotifyOnCancel(self, callback: Callable[[], None]) -> None: ...
3130

stubs/protobuf/google/protobuf/text_format.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _typeshed import SupportsWrite
22
from collections.abc import Callable, Iterable
3-
from typing import Any, Text, TypeVar
3+
from typing import Any, TypeVar
44
from typing_extensions import TypeAlias
55

66
from .descriptor import FieldDescriptor
@@ -18,11 +18,11 @@ class ParseError(Error):
1818

1919
class TextWriter:
2020
def __init__(self, as_utf8: bool) -> None: ...
21-
def write(self, val: Text) -> int: ...
21+
def write(self, val: str) -> int: ...
2222
def getvalue(self) -> str: ...
2323
def close(self) -> None: ...
2424

25-
_MessageFormatter: TypeAlias = Callable[[Message, int, bool], Text | None]
25+
_MessageFormatter: TypeAlias = Callable[[Message, int, bool], str | None]
2626

2727
def MessageToString(
2828
message: Message,
@@ -143,23 +143,23 @@ class _Printer:
143143
def PrintFieldValue(self, field: FieldDescriptor, value: Any) -> None: ...
144144

145145
def Parse(
146-
text: Text | bytes,
146+
text: str | bytes,
147147
message: _M,
148148
allow_unknown_extension: bool = ...,
149149
allow_field_number: bool = ...,
150150
descriptor_pool: DescriptorPool | None = ...,
151151
allow_unknown_field: bool = ...,
152152
) -> _M: ...
153153
def Merge(
154-
text: Text | bytes,
154+
text: str | bytes,
155155
message: _M,
156156
allow_unknown_extension: bool = ...,
157157
allow_field_number: bool = ...,
158158
descriptor_pool: DescriptorPool | None = ...,
159159
allow_unknown_field: bool = ...,
160160
) -> _M: ...
161161
def MergeLines(
162-
lines: Iterable[Text | bytes],
162+
lines: Iterable[str | bytes],
163163
message: _M,
164164
allow_unknown_extension: bool = ...,
165165
allow_field_number: bool = ...,
@@ -179,8 +179,8 @@ class _Parser:
179179
descriptor_pool: DescriptorPool | None = ...,
180180
allow_unknown_field: bool = ...,
181181
) -> None: ...
182-
def ParseLines(self, lines: Iterable[Text | bytes], message: _M) -> _M: ...
183-
def MergeLines(self, lines: Iterable[Text | bytes], message: _M) -> _M: ...
182+
def ParseLines(self, lines: Iterable[str | bytes], message: _M) -> _M: ...
183+
def MergeLines(self, lines: Iterable[str | bytes], message: _M) -> _M: ...
184184

185185
_ParseError: TypeAlias = ParseError
186186

@@ -203,7 +203,7 @@ class Tokenizer:
203203
def ConsumeFloat(self) -> float: ...
204204
def ConsumeBool(self) -> bool: ...
205205
def TryConsumeByteString(self) -> bool: ...
206-
def ConsumeString(self) -> Text: ...
206+
def ConsumeString(self) -> str: ...
207207
def ConsumeByteString(self) -> bytes: ...
208208
def ConsumeEnum(self, field: FieldDescriptor) -> int: ...
209209
def ParseErrorPreviousToken(self, message: Message) -> _ParseError: ...

0 commit comments

Comments
 (0)