Skip to content

add missing type hints for __class_getitem__ #5869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions stdlib/fileinput.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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] = ...,
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions stdlib/http/cookies.pyi
Original file line number Diff line number Diff line change
@@ -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")

Expand Down Expand Up @@ -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: ...
Expand Down
2 changes: 2 additions & 0 deletions stdlib/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
6 changes: 6 additions & 0 deletions stdlib/tempfile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down