Skip to content

Commit 2a461a2

Browse files
authored
Use a more precise return type for tokenize.untokenize() (#13366)
1 parent 67eebc5 commit 2a461a2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

stdlib/tokenize.pyi

+2-3
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,8 @@ class Untokenizer:
130130
if sys.version_info >= (3, 12):
131131
def escape_brackets(self, token: str) -> str: ...
132132

133-
# the docstring says "returns bytes" but is incorrect --
134-
# if the ENCODING token is missing, it skips the encode
135-
def untokenize(iterable: Iterable[_Token]) -> Any: ...
133+
# Returns str, unless the ENCODING token is present, in which case it returns bytes.
134+
def untokenize(iterable: Iterable[_Token]) -> str | Any: ...
136135
def detect_encoding(readline: Callable[[], bytes | bytearray]) -> tuple[str, Sequence[bytes]]: ...
137136
def tokenize(readline: Callable[[], bytes | bytearray]) -> Generator[TokenInfo, None, None]: ...
138137
def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ...

0 commit comments

Comments
 (0)