From 4849b072da0689dcf4cff1f9a9bc4404954fb2f5 Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Wed, 22 Apr 2026 18:12:55 +0800 Subject: [PATCH] [_io] Limit `io.text_encoding` argument to `str | None` (#15663) --- stdlib/_io.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/_io.pyi b/stdlib/_io.pyi index 2d2a60e4d..ed8eff275 100644 --- a/stdlib/_io.pyi +++ b/stdlib/_io.pyi @@ -9,7 +9,7 @@ from types import TracebackType from typing import IO, Any, BinaryIO, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload, type_check_only from typing_extensions import Self, disjoint_base -_T = TypeVar("_T") +_S = TypeVar("_S", bound=str) if sys.version_info >= (3, 14): DEFAULT_BUFFER_SIZE: Final = 131072 @@ -298,4 +298,4 @@ if sys.version_info >= (3, 10): @overload def text_encoding(encoding: None, stacklevel: int = 2, /) -> Literal["locale", "utf-8"]: ... @overload - def text_encoding(encoding: _T, stacklevel: int = 2, /) -> _T: ... + def text_encoding(encoding: _S, stacklevel: int = 2, /) -> _S: ...