diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index 9614ce10892c..175e0b2693ca 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -2,6 +2,9 @@ import sys from _typeshed import Self, StrOrBytesPath from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Union +if sys.version_info >= (3, 9): + from types import GenericAlias + if sys.version_info >= (3, 10): def input( files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ..., @@ -91,6 +94,8 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): def fileno(self) -> int: ... def isfirstline(self) -> bool: ... def isstdin(self) -> bool: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... if sys.version_info >= (3, 10): def hook_compressed( diff --git a/stdlib/http/cookies.pyi b/stdlib/http/cookies.pyi index 1fc2179ecfd6..99d2f6add836 100644 --- a/stdlib/http/cookies.pyi +++ b/stdlib/http/cookies.pyi @@ -1,6 +1,9 @@ import sys from typing import Any, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, TypeVar, Union, overload +if sys.version_info >= (3, 9): + from types import GenericAlias + _DataType = Union[str, Mapping[str, Union[str, Morsel[Any]]]] _T = TypeVar("_T") @@ -34,6 +37,8 @@ class Morsel(Dict[str, Any], Generic[_T]): def output(self, attrs: Optional[List[str]] = ..., header: str = ...) -> str: ... def js_output(self, attrs: Optional[List[str]] = ...) -> str: ... def OutputString(self, attrs: Optional[List[str]] = ...) -> str: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]): def __init__(self, input: Optional[_DataType] = ...) -> None: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 50d05b7381f2..71700daff545 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -311,6 +311,8 @@ class stat_result: @runtime_checkable class PathLike(Protocol[_AnyStr_co]): def __fspath__(self) -> _AnyStr_co: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... _FdOrAnyPath = Union[int, StrOrBytesPath] diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 9d2fb7a5a7c5..db45db67f21d 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -205,6 +205,10 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]): # It does not actually derive from IO[AnyStr], but it does implement the # protocol. class SpooledTemporaryFile(IO[AnyStr]): + @property + def encoding(self) -> str: ... # undocumented + @property + def newlines(self) -> str | Tuple[str, ...] | None: ... # undocumented # bytes needs to go first, as default mode is to open as bytes if sys.version_info >= (3, 8): @overload @@ -314,6 +318,8 @@ class SpooledTemporaryFile(IO[AnyStr]): def seekable(self) -> bool: ... def writable(self) -> bool: ... def __next__(self) -> AnyStr: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... class TemporaryDirectory(Generic[AnyStr]): name: AnyStr