Skip to content

Commit 39ede02

Browse files
authored
add missing type hints for __class_getitem__ (#5869)
1 parent 1cd719b commit 39ede02

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

stdlib/fileinput.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import sys
22
from _typeshed import Self, StrOrBytesPath
33
from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Union
44

5+
if sys.version_info >= (3, 9):
6+
from types import GenericAlias
7+
58
if sys.version_info >= (3, 10):
69
def input(
710
files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ...,
@@ -91,6 +94,8 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]):
9194
def fileno(self) -> int: ...
9295
def isfirstline(self) -> bool: ...
9396
def isstdin(self) -> bool: ...
97+
if sys.version_info >= (3, 9):
98+
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
9499

95100
if sys.version_info >= (3, 10):
96101
def hook_compressed(

stdlib/http/cookies.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import sys
22
from typing import Any, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, TypeVar, Union, overload
33

4+
if sys.version_info >= (3, 9):
5+
from types import GenericAlias
6+
47
_DataType = Union[str, Mapping[str, Union[str, Morsel[Any]]]]
58
_T = TypeVar("_T")
69

@@ -34,6 +37,8 @@ class Morsel(Dict[str, Any], Generic[_T]):
3437
def output(self, attrs: Optional[List[str]] = ..., header: str = ...) -> str: ...
3538
def js_output(self, attrs: Optional[List[str]] = ...) -> str: ...
3639
def OutputString(self, attrs: Optional[List[str]] = ...) -> str: ...
40+
if sys.version_info >= (3, 9):
41+
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
3742

3843
class BaseCookie(Dict[str, Morsel[_T]], Generic[_T]):
3944
def __init__(self, input: Optional[_DataType] = ...) -> None: ...

stdlib/os/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ class stat_result:
311311
@runtime_checkable
312312
class PathLike(Protocol[_AnyStr_co]):
313313
def __fspath__(self) -> _AnyStr_co: ...
314+
if sys.version_info >= (3, 9):
315+
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
314316

315317
_FdOrAnyPath = Union[int, StrOrBytesPath]
316318

stdlib/tempfile.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ class _TemporaryFileWrapper(Generic[AnyStr], IO[AnyStr]):
205205
# It does not actually derive from IO[AnyStr], but it does implement the
206206
# protocol.
207207
class SpooledTemporaryFile(IO[AnyStr]):
208+
@property
209+
def encoding(self) -> str: ... # undocumented
210+
@property
211+
def newlines(self) -> str | Tuple[str, ...] | None: ... # undocumented
208212
# bytes needs to go first, as default mode is to open as bytes
209213
if sys.version_info >= (3, 8):
210214
@overload
@@ -314,6 +318,8 @@ class SpooledTemporaryFile(IO[AnyStr]):
314318
def seekable(self) -> bool: ...
315319
def writable(self) -> bool: ...
316320
def __next__(self) -> AnyStr: ...
321+
if sys.version_info >= (3, 9):
322+
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
317323

318324
class TemporaryDirectory(Generic[AnyStr]):
319325
name: AnyStr

0 commit comments

Comments
 (0)