add missing type hints for __class_getitem__ (#5869)

This commit is contained in:
Anton Grübel
2021-08-07 23:12:53 +09:00
committed by GitHub
parent 1cd719ba8d
commit 39ede0242c
4 changed files with 18 additions and 0 deletions

View File

@@ -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(

View File

@@ -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: ...

View File

@@ -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]

View File

@@ -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