mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-03 01:53:24 +08:00
add missing type hints for __class_getitem__ (#5869)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user