Use new union syntax in rest of stdlib (#5884)

This commit is contained in:
Akuli
2021-08-08 16:44:30 +03:00
committed by GitHub
parent ebacd320a3
commit df6a211855
7 changed files with 177 additions and 228 deletions

View File

@@ -15,7 +15,7 @@ class LockType:
def locked(self) -> bool: ...
def __enter__(self) -> bool: ...
def __exit__(
self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]
self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...
def start_new_thread(function: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any] = ...) -> int: ...
@@ -33,9 +33,9 @@ if sys.version_info >= (3, 8):
@property
def exc_type(self) -> Type[BaseException]: ...
@property
def exc_value(self) -> Optional[BaseException]: ...
def exc_value(self) -> BaseException | None: ...
@property
def exc_traceback(self) -> Optional[TracebackType]: ...
def exc_traceback(self) -> TracebackType | None: ...
@property
def thread(self) -> Optional[Thread]: ...
def thread(self) -> Thread | None: ...
_excepthook: Callable[[_ExceptHookArgs], Any]

View File

@@ -26,17 +26,17 @@ FIRST_COMPLETED: str
ALL_COMPLETED: str
if sys.version_info >= (3, 10):
def as_completed(fs: Iterable[_FutureT[_T]], *, timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...
def as_completed(fs: Iterable[_FutureT[_T]], *, timeout: float | None = ...) -> Iterator[Future[_T]]: ...
else:
def as_completed(
fs: Iterable[_FutureT[_T]], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ...
fs: Iterable[_FutureT[_T]], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ...
) -> Iterator[Future[_T]]: ...
@overload
def ensure_future(coro_or_future: _FT, *, loop: Optional[AbstractEventLoop] = ...) -> _FT: ... # type: ignore
def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = ...) -> _FT: ... # type: ignore
@overload
def ensure_future(coro_or_future: Awaitable[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Task[_T]: ...
def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = ...) -> Task[_T]: ...
# Prior to Python 3.7 'async' was an alias for 'ensure_future'.
# It became a keyword in 3.7.
@@ -91,11 +91,11 @@ if sys.version_info >= (3, 10):
return_exceptions: bool = ...,
) -> Future[List[Any]]: ...
@overload
def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: bool = ...) -> Future[Tuple[Union[_T1, BaseException]]]: ...
def gather(coro_or_future1: _FutureT[_T1], *, return_exceptions: bool = ...) -> Future[Tuple[_T1 | BaseException]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], *, return_exceptions: bool = ...
) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException]]]: ...
) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1],
@@ -103,7 +103,7 @@ if sys.version_info >= (3, 10):
coro_or_future3: _FutureT[_T3],
*,
return_exceptions: bool = ...,
) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException]]]: ...
) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1],
@@ -112,9 +112,7 @@ if sys.version_info >= (3, 10):
coro_or_future4: _FutureT[_T4],
*,
return_exceptions: bool = ...,
) -> Future[
Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException], Union[_T4, BaseException]]
]: ...
) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1],
@@ -125,26 +123,20 @@ if sys.version_info >= (3, 10):
*,
return_exceptions: bool = ...,
) -> Future[
Tuple[
Union[_T1, BaseException],
Union[_T2, BaseException],
Union[_T3, BaseException],
Union[_T4, BaseException],
Union[_T5, BaseException],
]
Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ...
else:
@overload
def gather(
coro_or_future1: _FutureT[_T1], *, loop: Optional[AbstractEventLoop] = ..., return_exceptions: Literal[False] = ...
coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: Literal[False] = ...
) -> Future[Tuple[_T1]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1],
coro_or_future2: _FutureT[_T2],
*,
loop: Optional[AbstractEventLoop] = ...,
loop: AbstractEventLoop | None = ...,
return_exceptions: Literal[False] = ...,
) -> Future[Tuple[_T1, _T2]]: ...
@overload
@@ -153,7 +145,7 @@ else:
coro_or_future2: _FutureT[_T2],
coro_or_future3: _FutureT[_T3],
*,
loop: Optional[AbstractEventLoop] = ...,
loop: AbstractEventLoop | None = ...,
return_exceptions: Literal[False] = ...,
) -> Future[Tuple[_T1, _T2, _T3]]: ...
@overload
@@ -163,7 +155,7 @@ else:
coro_or_future3: _FutureT[_T3],
coro_or_future4: _FutureT[_T4],
*,
loop: Optional[AbstractEventLoop] = ...,
loop: AbstractEventLoop | None = ...,
return_exceptions: Literal[False] = ...,
) -> Future[Tuple[_T1, _T2, _T3, _T4]]: ...
@overload
@@ -174,7 +166,7 @@ else:
coro_or_future4: _FutureT[_T4],
coro_or_future5: _FutureT[_T5],
*,
loop: Optional[AbstractEventLoop] = ...,
loop: AbstractEventLoop | None = ...,
return_exceptions: Literal[False] = ...,
) -> Future[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
@overload
@@ -186,30 +178,30 @@ else:
coro_or_future5: _FutureT[Any],
coro_or_future6: _FutureT[Any],
*coros_or_futures: _FutureT[Any],
loop: Optional[AbstractEventLoop] = ...,
loop: AbstractEventLoop | None = ...,
return_exceptions: bool = ...,
) -> Future[List[Any]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1], *, loop: Optional[AbstractEventLoop] = ..., return_exceptions: bool = ...
) -> Future[Tuple[Union[_T1, BaseException]]]: ...
coro_or_future1: _FutureT[_T1], *, loop: AbstractEventLoop | None = ..., return_exceptions: bool = ...
) -> Future[Tuple[_T1 | BaseException]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1],
coro_or_future2: _FutureT[_T2],
*,
loop: Optional[AbstractEventLoop] = ...,
loop: AbstractEventLoop | None = ...,
return_exceptions: bool = ...,
) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException]]]: ...
) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1],
coro_or_future2: _FutureT[_T2],
coro_or_future3: _FutureT[_T3],
*,
loop: Optional[AbstractEventLoop] = ...,
loop: AbstractEventLoop | None = ...,
return_exceptions: bool = ...,
) -> Future[Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException]]]: ...
) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1],
@@ -217,11 +209,9 @@ else:
coro_or_future3: _FutureT[_T3],
coro_or_future4: _FutureT[_T4],
*,
loop: Optional[AbstractEventLoop] = ...,
loop: AbstractEventLoop | None = ...,
return_exceptions: bool = ...,
) -> Future[
Tuple[Union[_T1, BaseException], Union[_T2, BaseException], Union[_T3, BaseException], Union[_T4, BaseException]]
]: ...
) -> Future[Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
@overload
def gather(
coro_or_future1: _FutureT[_T1],
@@ -230,16 +220,10 @@ else:
coro_or_future4: _FutureT[_T4],
coro_or_future5: _FutureT[_T5],
*,
loop: Optional[AbstractEventLoop] = ...,
loop: AbstractEventLoop | None = ...,
return_exceptions: bool = ...,
) -> Future[
Tuple[
Union[_T1, BaseException],
Union[_T2, BaseException],
Union[_T3, BaseException],
Union[_T4, BaseException],
Union[_T5, BaseException],
]
Tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
]: ...
def run_coroutine_threadsafe(coro: _FutureT[_T], loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
@@ -248,68 +232,62 @@ if sys.version_info >= (3, 10):
def shield(arg: _FutureT[_T]) -> Future[_T]: ...
def sleep(delay: float, result: _T = ...) -> Future[_T]: ...
@overload
def wait(fs: Iterable[_FT], *, timeout: Optional[float] = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore
def wait(fs: Iterable[_FT], *, timeout: float | None = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore
@overload
def wait(
fs: Iterable[Awaitable[_T]], *, timeout: Optional[float] = ..., return_when: str = ...
fs: Iterable[Awaitable[_T]], *, timeout: float | None = ..., return_when: str = ...
) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ...
def wait_for(fut: _FutureT[_T], timeout: Optional[float]) -> Future[_T]: ...
def wait_for(fut: _FutureT[_T], timeout: float | None) -> Future[_T]: ...
else:
def shield(arg: _FutureT[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def sleep(delay: float, result: _T = ..., *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ...
def sleep(delay: float, result: _T = ..., *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ...
@overload
def wait(fs: Iterable[_FT], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore
def wait(fs: Iterable[_FT], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...) -> Future[Tuple[Set[_FT], Set[_FT]]]: ... # type: ignore
@overload
def wait(
fs: Iterable[Awaitable[_T]],
*,
loop: Optional[AbstractEventLoop] = ...,
timeout: Optional[float] = ...,
return_when: str = ...,
fs: Iterable[Awaitable[_T]], *, loop: AbstractEventLoop | None = ..., timeout: float | None = ..., return_when: str = ...
) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ...
def wait_for(fut: _FutureT[_T], timeout: Optional[float], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def wait_for(fut: _FutureT[_T], timeout: float | None, *, loop: AbstractEventLoop | None = ...) -> Future[_T]: ...
class Task(Future[_T], Generic[_T]):
if sys.version_info >= (3, 8):
def __init__(
self,
coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]],
coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T],
*,
loop: AbstractEventLoop = ...,
name: Optional[str] = ...,
name: str | None = ...,
) -> None: ...
else:
def __init__(
self, coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...
self, coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, loop: AbstractEventLoop = ...
) -> None: ...
def __repr__(self) -> str: ...
if sys.version_info >= (3, 8):
def get_coro(self) -> Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]]: ...
def get_coro(self) -> Generator[_TaskYieldType, None, _T] | Awaitable[_T]: ...
def get_name(self) -> str: ...
def set_name(self, __value: object) -> None: ...
def get_stack(self, *, limit: Optional[int] = ...) -> List[FrameType]: ...
def print_stack(self, *, limit: Optional[int] = ..., file: Optional[TextIO] = ...) -> None: ...
def get_stack(self, *, limit: int | None = ...) -> List[FrameType]: ...
def print_stack(self, *, limit: int | None = ..., file: TextIO | None = ...) -> None: ...
if sys.version_info >= (3, 9):
def cancel(self, msg: Optional[str] = ...) -> bool: ...
def cancel(self, msg: str | None = ...) -> bool: ...
else:
def cancel(self) -> bool: ...
if sys.version_info < (3, 9):
@classmethod
def current_task(cls, loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ...
def current_task(cls, loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ...
@classmethod
def all_tasks(cls, loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
def all_tasks(cls, loop: AbstractEventLoop | None = ...) -> Set[Task[Any]]: ...
if sys.version_info < (3, 7):
def _wakeup(self, fut: Future[Any]) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
if sys.version_info >= (3, 7):
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...
def all_tasks(loop: AbstractEventLoop | None = ...) -> Set[Task[Any]]: ...
if sys.version_info >= (3, 8):
def create_task(
coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]], *, name: Optional[str] = ...
) -> Task[_T]: ...
def create_task(coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T], *, name: str | None = ...) -> Task[_T]: ...
else:
def create_task(coro: Union[Generator[_TaskYieldType, None, _T], Awaitable[_T]]) -> Task[_T]: ...
def current_task(loop: Optional[AbstractEventLoop] = ...) -> Optional[Task[Any]]: ...
def create_task(coro: Generator[_TaskYieldType, None, _T] | Awaitable[_T]) -> Task[_T]: ...
def current_task(loop: AbstractEventLoop | None = ...) -> Task[Any] | None: ...

View File

@@ -17,7 +17,6 @@ from typing import (
Tuple,
Type,
TypeVar,
Union,
overload,
)
from typing_extensions import Literal
@@ -64,33 +63,33 @@ class RawConfigParser(_parser):
@overload
def __init__(
self,
defaults: Optional[Mapping[str, Optional[str]]] = ...,
defaults: Mapping[str, str | None] | None = ...,
dict_type: Type[Mapping[str, str]] = ...,
allow_no_value: Literal[True] = ...,
*,
delimiters: Sequence[str] = ...,
comment_prefixes: Sequence[str] = ...,
inline_comment_prefixes: Optional[Sequence[str]] = ...,
inline_comment_prefixes: Sequence[str] | None = ...,
strict: bool = ...,
empty_lines_in_values: bool = ...,
default_section: str = ...,
interpolation: Optional[Interpolation] = ...,
interpolation: Interpolation | None = ...,
converters: _converters = ...,
) -> None: ...
@overload
def __init__(
self,
defaults: Optional[_section] = ...,
defaults: _section | None = ...,
dict_type: Type[Mapping[str, str]] = ...,
allow_no_value: bool = ...,
*,
delimiters: Sequence[str] = ...,
comment_prefixes: Sequence[str] = ...,
inline_comment_prefixes: Optional[Sequence[str]] = ...,
inline_comment_prefixes: Sequence[str] | None = ...,
strict: bool = ...,
empty_lines_in_values: bool = ...,
default_section: str = ...,
interpolation: Optional[Interpolation] = ...,
interpolation: Interpolation | None = ...,
converters: _converters = ...,
) -> None: ...
def __len__(self) -> int: ...
@@ -104,31 +103,31 @@ class RawConfigParser(_parser):
def has_section(self, section: str) -> bool: ...
def options(self, section: str) -> List[str]: ...
def has_option(self, section: str, option: str) -> bool: ...
def read(self, filenames: Union[_Path, Iterable[_Path]], encoding: Optional[str] = ...) -> List[str]: ...
def read_file(self, f: Iterable[str], source: Optional[str] = ...) -> None: ...
def read(self, filenames: _Path | Iterable[_Path], encoding: str | None = ...) -> List[str]: ...
def read_file(self, f: Iterable[str], source: str | None = ...) -> None: ...
def read_string(self, string: str, source: str = ...) -> None: ...
def read_dict(self, dictionary: Mapping[str, Mapping[str, Any]], source: str = ...) -> None: ...
def readfp(self, fp: Iterable[str], filename: Optional[str] = ...) -> None: ...
def readfp(self, fp: Iterable[str], filename: str | None = ...) -> None: ...
# These get* methods are partially applied (with the same names) in
# SectionProxy; the stubs should be kept updated together
@overload
def getint(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> int: ...
def getint(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> int: ...
@overload
def getint(
self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ...
) -> Union[int, _T]: ...
self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ...
) -> int | _T: ...
@overload
def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> float: ...
def getfloat(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> float: ...
@overload
def getfloat(
self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ...
) -> Union[float, _T]: ...
self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ...
) -> float | _T: ...
@overload
def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> bool: ...
def getboolean(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> bool: ...
@overload
def getboolean(
self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T = ...
) -> Union[bool, _T]: ...
self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T = ...
) -> bool | _T: ...
def _get_conv(
self,
section: str,
@@ -136,21 +135,19 @@ class RawConfigParser(_parser):
conv: Callable[[str], _T],
*,
raw: bool = ...,
vars: Optional[_section] = ...,
vars: _section | None = ...,
fallback: _T = ...,
) -> _T: ...
# This is incompatible with MutableMapping so we ignore the type
@overload # type: ignore
def get(self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> str: ...
def get(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ...) -> str: ...
@overload
def get(
self, section: str, option: str, *, raw: bool = ..., vars: Optional[_section] = ..., fallback: _T
) -> Union[str, _T]: ...
def get(self, section: str, option: str, *, raw: bool = ..., vars: _section | None = ..., fallback: _T) -> str | _T: ...
@overload
def items(self, *, raw: bool = ..., vars: Optional[_section] = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ...
def items(self, *, raw: bool = ..., vars: _section | None = ...) -> AbstractSet[Tuple[str, SectionProxy]]: ...
@overload
def items(self, section: str, raw: bool = ..., vars: Optional[_section] = ...) -> List[Tuple[str, str]]: ...
def set(self, section: str, option: str, value: Optional[str] = ...) -> None: ...
def items(self, section: str, raw: bool = ..., vars: _section | None = ...) -> List[Tuple[str, str]]: ...
def set(self, section: str, option: str, value: str | None = ...) -> None: ...
def write(self, fp: SupportsWrite[str], space_around_delimiters: bool = ...) -> None: ...
def remove_option(self, section: str, option: str) -> bool: ...
def remove_section(self, section: str) -> bool: ...
@@ -171,25 +168,21 @@ class SectionProxy(MutableMapping[str, str]):
def parser(self) -> RawConfigParser: ...
@property
def name(self) -> str: ...
def get(self, option: str, fallback: Optional[str] = ..., *, raw: bool = ..., vars: Optional[_section] = ..., _impl: Optional[Any] = ..., **kwargs: Any) -> str: ... # type: ignore
def get(self, option: str, fallback: str | None = ..., *, raw: bool = ..., vars: _section | None = ..., _impl: Any | None = ..., **kwargs: Any) -> str: ... # type: ignore
# These are partially-applied version of the methods with the same names in
# RawConfigParser; the stubs should be kept updated together
@overload
def getint(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> int: ...
def getint(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> int: ...
@overload
def getint(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ...) -> Union[int, _T]: ...
def getint(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> int | _T: ...
@overload
def getfloat(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> float: ...
def getfloat(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> float: ...
@overload
def getfloat(
self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ...
) -> Union[float, _T]: ...
def getfloat(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> float | _T: ...
@overload
def getboolean(self, option: str, *, raw: bool = ..., vars: Optional[_section] = ...) -> bool: ...
def getboolean(self, option: str, *, raw: bool = ..., vars: _section | None = ...) -> bool: ...
@overload
def getboolean(
self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ...
) -> Union[bool, _T]: ...
def getboolean(self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: _section | None = ...) -> bool | _T: ...
# SectionProxy can have arbitrary attributes when custom converters are used
def __getattr__(self, key: str) -> Callable[..., Any]: ...
@@ -197,7 +190,7 @@ class ConverterMapping(MutableMapping[str, Optional[_converter]]):
GETTERCRE: Pattern[Any]
def __init__(self, parser: RawConfigParser) -> None: ...
def __getitem__(self, key: str) -> _converter: ...
def __setitem__(self, key: str, value: Optional[_converter]) -> None: ...
def __setitem__(self, key: str, value: _converter | None) -> None: ...
def __delitem__(self, key: str) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __len__(self) -> int: ...
@@ -212,16 +205,16 @@ class NoSectionError(Error):
class DuplicateSectionError(Error):
section: str
source: Optional[str]
lineno: Optional[int]
def __init__(self, section: str, source: Optional[str] = ..., lineno: Optional[int] = ...) -> None: ...
source: str | None
lineno: int | None
def __init__(self, section: str, source: str | None = ..., lineno: int | None = ...) -> None: ...
class DuplicateOptionError(Error):
section: str
option: str
source: Optional[str]
lineno: Optional[int]
def __init__(self, section: str, option: str, source: Optional[str] = ..., lineno: Optional[int] = ...) -> None: ...
source: str | None
lineno: int | None
def __init__(self, section: str, option: str, source: str | None = ..., lineno: int | None = ...) -> None: ...
class NoOptionError(Error):
section: str
@@ -245,7 +238,7 @@ class InterpolationSyntaxError(InterpolationError): ...
class ParsingError(Error):
source: str
errors: List[Tuple[int, str]]
def __init__(self, source: Optional[str] = ..., filename: Optional[str] = ...) -> None: ...
def __init__(self, source: str | None = ..., filename: str | None = ...) -> None: ...
def append(self, lineno: int, line: str) -> None: ...
class MissingSectionHeaderError(ParsingError):

View File

@@ -1,7 +1,7 @@
import sys
from email.errors import HeaderParseError, MessageDefect
from email.policy import Policy
from typing import Any, Iterable, Iterator, List, Optional, Pattern, Set, Tuple, Type, TypeVar, Union
from typing import Any, Iterable, Iterator, List, Pattern, Set, Tuple, Type, TypeVar, Union
from typing_extensions import Final
_T = TypeVar("_T")
@@ -24,7 +24,7 @@ if sys.version_info >= (3, 7):
rfc2047_matcher: Pattern[str]
class TokenList(List[Union[TokenList, Terminal]]):
token_type: Optional[str] = ...
token_type: str | None = ...
syntactic_break: bool = ...
ew_combine_allowed: bool = ...
defects: List[MessageDefect] = ...
@@ -69,9 +69,9 @@ class Token(TokenList):
class EncodedWord(TokenList):
token_type: str = ...
cte: Optional[str] = ...
charset: Optional[str] = ...
lang: Optional[str] = ...
cte: str | None = ...
charset: str | None = ...
lang: str | None = ...
class QuotedString(TokenList):
token_type: str = ...
@@ -145,7 +145,7 @@ class NameAddr(TokenList):
@property
def domain(self) -> str: ...
@property
def route(self) -> Optional[List[Domain]]: ...
def route(self) -> List[Domain] | None: ...
@property
def addr_spec(self) -> str: ...
@@ -156,7 +156,7 @@ class AngleAddr(TokenList):
@property
def domain(self) -> str: ...
@property
def route(self) -> Optional[List[Domain]]: ...
def route(self) -> List[Domain] | None: ...
@property
def addr_spec(self) -> str: ...
@@ -247,8 +247,8 @@ class DomainLiteral(TokenList):
class MIMEVersion(TokenList):
token_type: str = ...
major: Optional[int] = ...
minor: Optional[int] = ...
major: int | None = ...
minor: int | None = ...
class Parameter(TokenList):
token_type: str = ...
@@ -270,7 +270,7 @@ class Attribute(TokenList):
class Section(TokenList):
token_type: str = ...
number: Optional[int] = ...
number: int | None = ...
class Value(TokenList):
token_type: str = ...

View File

@@ -29,7 +29,6 @@ from typing import (
Mapping,
MutableMapping,
NoReturn,
Optional,
Protocol,
Sequence,
Set,
@@ -171,7 +170,7 @@ sep: str
if sys.platform == "win32":
altsep: str
else:
altsep: Optional[str]
altsep: str | None
extsep: str
pathsep: str
defpath: str
@@ -337,7 +336,7 @@ if sys.platform != "win32":
if sys.version_info >= (3, 7):
# f_fsid was added in https://github.com/python/cpython/pull/4571
class statvfs_result(_Tuple10Int): # Unix only
def __new__(cls, seq: Union[_Tuple10Int, _Tuple11Int], dict: Dict[str, int] = ...) -> statvfs_result: ...
def __new__(cls, seq: _Tuple10Int | _Tuple11Int, dict: Dict[str, int] = ...) -> statvfs_result: ...
n_fields: int
n_sequence_fields: int
n_unnamed_fields: int
@@ -379,7 +378,7 @@ def fspath(path: str) -> str: ...
def fspath(path: bytes) -> bytes: ...
@overload
def fspath(path: PathLike[AnyStr]) -> AnyStr: ...
def get_exec_path(env: Optional[Mapping[str, str]] = ...) -> List[str]: ...
def get_exec_path(env: Mapping[str, str] | None = ...) -> List[str]: ...
# NOTE: get_exec_path(): returns List[bytes] when env not None
def getlogin() -> str: ...
@@ -423,20 +422,20 @@ if sys.platform != "win32":
def uname() -> uname_result: ...
@overload
def getenv(key: str) -> Optional[str]: ...
def getenv(key: str) -> str | None: ...
@overload
def getenv(key: str, default: _T) -> Union[str, _T]: ...
def getenv(key: str, default: _T) -> str | _T: ...
if sys.platform != "win32":
@overload
def getenvb(key: bytes) -> Optional[bytes]: ...
def getenvb(key: bytes) -> bytes | None: ...
@overload
def getenvb(key: bytes, default: _T) -> Union[bytes, _T]: ...
def getenvb(key: bytes, default: _T) -> bytes | _T: ...
def putenv(__name: Union[bytes, str], __value: Union[bytes, str]) -> None: ...
def putenv(__name: bytes | str, __value: bytes | str) -> None: ...
if sys.platform != "win32":
def unsetenv(__name: Union[bytes, str]) -> None: ...
def unsetenv(__name: bytes | str) -> None: ...
_Opener = Callable[[str, int], int]
@@ -445,11 +444,11 @@ def fdopen(
fd: int,
mode: OpenTextMode = ...,
buffering: int = ...,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...,
encoding: str | None = ...,
errors: str | None = ...,
newline: str | None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
opener: _Opener | None = ...,
) -> _TextIOWrapper: ...
@overload
def fdopen(
@@ -460,7 +459,7 @@ def fdopen(
errors: None = ...,
newline: None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
opener: _Opener | None = ...,
) -> FileIO: ...
@overload
def fdopen(
@@ -471,7 +470,7 @@ def fdopen(
errors: None = ...,
newline: None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
opener: _Opener | None = ...,
) -> BufferedRandom: ...
@overload
def fdopen(
@@ -482,7 +481,7 @@ def fdopen(
errors: None = ...,
newline: None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
opener: _Opener | None = ...,
) -> BufferedWriter: ...
@overload
def fdopen(
@@ -493,7 +492,7 @@ def fdopen(
errors: None = ...,
newline: None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
opener: _Opener | None = ...,
) -> BufferedReader: ...
@overload
def fdopen(
@@ -504,22 +503,22 @@ def fdopen(
errors: None = ...,
newline: None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
opener: _Opener | None = ...,
) -> BinaryIO: ...
@overload
def fdopen(
fd: int,
mode: str,
buffering: int = ...,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...,
encoding: str | None = ...,
errors: str | None = ...,
newline: str | None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
opener: _Opener | None = ...,
) -> IO[Any]: ...
def close(fd: int) -> None: ...
def closerange(__fd_low: int, __fd_high: int) -> None: ...
def device_encoding(fd: int) -> Optional[str]: ...
def device_encoding(fd: int) -> str | None: ...
def dup(__fd: int) -> int: ...
if sys.version_info >= (3, 7):
@@ -531,7 +530,7 @@ else:
def fstat(fd: int) -> stat_result: ...
def fsync(fd: FileDescriptorLike) -> None: ...
def lseek(__fd: int, __position: int, __how: int) -> int: ...
def open(path: StrOrBytesPath, flags: int, mode: int = ..., *, dir_fd: Optional[int] = ...) -> int: ...
def open(path: StrOrBytesPath, flags: int, mode: int = ..., *, dir_fd: int | None = ...) -> int: ...
def pipe() -> Tuple[int, int]: ...
def read(__fd: int, __length: int) -> bytes: ...
@@ -541,7 +540,7 @@ if sys.platform != "win32":
def fchown(fd: int, uid: int, gid: int) -> None: ...
if sys.platform != "darwin":
def fdatasync(fd: FileDescriptorLike) -> None: ... # Unix only, not Mac
def fpathconf(__fd: int, __name: Union[str, int]) -> int: ...
def fpathconf(__fd: int, __name: str | int) -> int: ...
def fstatvfs(__fd: int) -> statvfs_result: ...
def ftruncate(__fd: int, __length: int) -> None: ...
def get_blocking(__fd: int) -> bool: ...
@@ -556,7 +555,7 @@ if sys.platform != "win32":
def pread(__fd: int, __length: int, __offset: int) -> bytes: ...
def pwrite(__fd: int, __buffer: bytes, __offset: int) -> int: ...
@overload
def sendfile(out_fd: int, in_fd: int, offset: Optional[int], count: int) -> int: ...
def sendfile(out_fd: int, in_fd: int, offset: int | None, count: int) -> int: ...
@overload
def sendfile(
out_fd: int,
@@ -586,7 +585,7 @@ if sys.platform != "win32":
def write(__fd: int, __data: bytes) -> int: ...
def access(
path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., effective_ids: bool = ..., follow_symlinks: bool = ...
path: _FdOrAnyPath, mode: int, *, dir_fd: int | None = ..., effective_ids: bool = ..., follow_symlinks: bool = ...
) -> bool: ...
def chdir(path: _FdOrAnyPath) -> None: ...
@@ -595,12 +594,12 @@ if sys.platform != "win32":
def getcwd() -> str: ...
def getcwdb() -> bytes: ...
def chmod(path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ...
def chmod(path: _FdOrAnyPath, mode: int, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> None: ...
if sys.platform != "win32":
def chflags(path: StrOrBytesPath, flags: int, follow_symlinks: bool = ...) -> None: ... # some flavors of Unix
def chown(
path: _FdOrAnyPath, uid: int, gid: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...
path: _FdOrAnyPath, uid: int, gid: int, *, dir_fd: int | None = ..., follow_symlinks: bool = ...
) -> None: ... # Unix only
if sys.platform != "win32":
@@ -614,36 +613,32 @@ def link(
src: StrOrBytesPath,
dst: StrOrBytesPath,
*,
src_dir_fd: Optional[int] = ...,
dst_dir_fd: Optional[int] = ...,
src_dir_fd: int | None = ...,
dst_dir_fd: int | None = ...,
follow_symlinks: bool = ...,
) -> None: ...
def lstat(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> stat_result: ...
def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ...
def lstat(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> stat_result: ...
def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None: ...
if sys.platform != "win32":
def mkfifo(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only
def mkfifo(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None: ... # Unix only
def makedirs(name: StrOrBytesPath, mode: int = ..., exist_ok: bool = ...) -> None: ...
if sys.platform != "win32":
def mknod(path: StrOrBytesPath, mode: int = ..., device: int = ..., *, dir_fd: Optional[int] = ...) -> None: ...
def mknod(path: StrOrBytesPath, mode: int = ..., device: int = ..., *, dir_fd: int | None = ...) -> None: ...
def major(__device: int) -> int: ...
def minor(__device: int) -> int: ...
def makedev(__major: int, __minor: int) -> int: ...
def pathconf(path: _FdOrAnyPath, name: Union[str, int]) -> int: ... # Unix only
def pathconf(path: _FdOrAnyPath, name: str | int) -> int: ... # Unix only
def readlink(path: Union[AnyStr, PathLike[AnyStr]], *, dir_fd: Optional[int] = ...) -> AnyStr: ...
def remove(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ...
def readlink(path: AnyStr | PathLike[AnyStr], *, dir_fd: int | None = ...) -> AnyStr: ...
def remove(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ...
def removedirs(name: StrOrBytesPath) -> None: ...
def rename(
src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...
) -> None: ...
def rename(src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ...) -> None: ...
def renames(old: StrOrBytesPath, new: StrOrBytesPath) -> None: ...
def replace(
src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...
) -> None: ...
def rmdir(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ...
def replace(src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ...) -> None: ...
def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ...
class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]):
def __next__(self) -> DirEntry[AnyStr]: ...
@@ -655,15 +650,15 @@ if sys.version_info >= (3, 7):
@overload
def scandir(path: int) -> _ScandirIterator[str]: ...
@overload
def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ...
def scandir(path: AnyStr | PathLike[AnyStr]) -> _ScandirIterator[AnyStr]: ...
else:
@overload
def scandir(path: None = ...) -> _ScandirIterator[str]: ...
@overload
def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ...
def scandir(path: AnyStr | PathLike[AnyStr]) -> _ScandirIterator[AnyStr]: ...
def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ...
def stat(path: _FdOrAnyPath, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> stat_result: ...
if sys.version_info < (3, 7):
@overload
@@ -674,28 +669,26 @@ if sys.version_info < (3, 7):
if sys.platform != "win32":
def statvfs(path: _FdOrAnyPath) -> statvfs_result: ... # Unix only
def symlink(
src: StrOrBytesPath, dst: StrOrBytesPath, target_is_directory: bool = ..., *, dir_fd: Optional[int] = ...
) -> None: ...
def symlink(src: StrOrBytesPath, dst: StrOrBytesPath, target_is_directory: bool = ..., *, dir_fd: int | None = ...) -> None: ...
if sys.platform != "win32":
def sync() -> None: ... # Unix only
def truncate(path: _FdOrAnyPath, length: int) -> None: ... # Unix only up to version 3.4
def unlink(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ...
def unlink(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ...
def utime(
path: _FdOrAnyPath,
times: Optional[Union[Tuple[int, int], Tuple[float, float]]] = ...,
times: Tuple[int, int] | Tuple[float, float] | None = ...,
*,
ns: Tuple[int, int] = ...,
dir_fd: Optional[int] = ...,
dir_fd: int | None = ...,
follow_symlinks: bool = ...,
) -> None: ...
_OnError = Callable[[OSError], Any]
def walk(
top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ..., onerror: Optional[_OnError] = ..., followlinks: bool = ...
top: AnyStr | PathLike[AnyStr], topdown: bool = ..., onerror: _OnError | None = ..., followlinks: bool = ...
) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ...
if sys.platform != "win32":
@@ -704,32 +697,32 @@ if sys.platform != "win32":
def fwalk(
top: StrPath = ...,
topdown: bool = ...,
onerror: Optional[_OnError] = ...,
onerror: _OnError | None = ...,
*,
follow_symlinks: bool = ...,
dir_fd: Optional[int] = ...,
dir_fd: int | None = ...,
) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
@overload
def fwalk(
top: bytes,
topdown: bool = ...,
onerror: Optional[_OnError] = ...,
onerror: _OnError | None = ...,
*,
follow_symlinks: bool = ...,
dir_fd: Optional[int] = ...,
dir_fd: int | None = ...,
) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ...
else:
def fwalk(
top: StrPath = ...,
topdown: bool = ...,
onerror: Optional[_OnError] = ...,
onerror: _OnError | None = ...,
*,
follow_symlinks: bool = ...,
dir_fd: Optional[int] = ...,
dir_fd: int | None = ...,
) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
if sys.platform == "linux":
def getxattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> bytes: ...
def listxattr(path: Optional[_FdOrAnyPath] = ..., *, follow_symlinks: bool = ...) -> List[str]: ...
def listxattr(path: _FdOrAnyPath | None = ..., *, follow_symlinks: bool = ...) -> List[str]: ...
def removexattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> None: ...
def setxattr(
path: _FdOrAnyPath, attribute: StrOrBytesPath, value: bytes, flags: int = ..., *, follow_symlinks: bool = ...
@@ -780,7 +773,7 @@ if sys.platform != "win32":
class _wrap_close(_TextIOWrapper):
def __init__(self, stream: _TextIOWrapper, proc: Popen[str]) -> None: ...
def close(self) -> Optional[int]: ... # type: ignore
def close(self) -> int | None: ... # type: ignore
def popen(cmd: str, mode: str = ..., buffering: int = ...) -> _wrap_close: ...
def spawnl(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: ...
@@ -799,7 +792,7 @@ def times() -> times_result: ...
def waitpid(__pid: int, __options: int) -> Tuple[int, int]: ...
if sys.platform == "win32":
def startfile(path: StrOrBytesPath, operation: Optional[str] = ...) -> None: ...
def startfile(path: StrOrBytesPath, operation: str | None = ...) -> None: ...
else:
# Unix only
@@ -838,13 +831,13 @@ if sys.platform != "win32":
def sched_setaffinity(pid: int, mask: Iterable[int]) -> None: ... # some flavors of Unix
def sched_getaffinity(pid: int) -> Set[int]: ... # some flavors of Unix
def cpu_count() -> Optional[int]: ...
def cpu_count() -> int | None: ...
if sys.platform != "win32":
# Unix only
def confstr(__name: Union[str, int]) -> Optional[str]: ...
def confstr(__name: str | int) -> str | None: ...
def getloadavg() -> Tuple[float, float, float]: ...
def sysconf(__name: Union[str, int]) -> int: ...
def sysconf(__name: str | int) -> int: ...
if sys.platform == "linux":
def getrandom(size: int, flags: int = ...) -> bytes: ...
@@ -854,16 +847,16 @@ def urandom(__size: int) -> bytes: ...
if sys.version_info >= (3, 7) and sys.platform != "win32":
def register_at_fork(
*,
before: Optional[Callable[..., Any]] = ...,
after_in_parent: Optional[Callable[..., Any]] = ...,
after_in_child: Optional[Callable[..., Any]] = ...,
before: Callable[..., Any] | None = ...,
after_in_parent: Callable[..., Any] | None = ...,
after_in_child: Callable[..., Any] | None = ...,
) -> None: ...
if sys.version_info >= (3, 8):
if sys.platform == "win32":
class _AddedDllDirectory:
path: Optional[str]
def __init__(self, path: Optional[str], cookie: _T, remove_dll_directory: Callable[[_T], Any]) -> None: ...
path: str | None
def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], Any]) -> None: ...
def close(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, *args: Any) -> None: ...

View File

@@ -15,31 +15,21 @@ if sys.version_info >= (3, 8):
def release(self) -> None: ...
_BufferCallback = Optional[Callable[[PickleBuffer], Any]]
def dump(
obj: Any,
file: IO[bytes],
protocol: Optional[int] = ...,
*,
fix_imports: bool = ...,
buffer_callback: _BufferCallback = ...,
obj: Any, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ...
) -> None: ...
def dumps(
obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ...
obj: Any, protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ...
) -> bytes: ...
def load(
file: IO[bytes],
*,
fix_imports: bool = ...,
encoding: str = ...,
errors: str = ...,
buffers: Optional[Iterable[Any]] = ...,
file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Iterable[Any] | None = ...
) -> Any: ...
def loads(
__data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Optional[Iterable[Any]] = ...
__data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Iterable[Any] | None = ...
) -> Any: ...
else:
def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ...
def dumps(obj: Any, protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> bytes: ...
def dump(obj: Any, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ...
def dumps(obj: Any, protocol: int | None = ..., *, fix_imports: bool = ...) -> bytes: ...
def load(file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ...
def loads(data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ...
@@ -63,16 +53,11 @@ class Pickler:
if sys.version_info >= (3, 8):
def __init__(
self,
file: IO[bytes],
protocol: Optional[int] = ...,
*,
fix_imports: bool = ...,
buffer_callback: _BufferCallback = ...,
self, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ...
) -> None: ...
def reducer_override(self, obj: Any) -> Any: ...
else:
def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *, fix_imports: bool = ...) -> None: ...
def __init__(self, file: IO[bytes], protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ...
def dump(self, __obj: Any) -> None: ...
def clear_memo(self) -> None: ...
def persistent_id(self, obj: Any) -> Any: ...
@@ -88,7 +73,7 @@ class Unpickler:
fix_imports: bool = ...,
encoding: str = ...,
errors: str = ...,
buffers: Optional[Iterable[Any]] = ...,
buffers: Iterable[Any] | None = ...,
) -> None: ...
else:
def __init__(self, file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> None: ...

View File

@@ -1,7 +1,7 @@
import typing
from _typeshed import StrPath
from datetime import tzinfo
from typing import Any, Iterable, Optional, Protocol, Sequence, Set, Type
from typing import Any, Iterable, Protocol, Sequence, Set, Type
_T = typing.TypeVar("_T", bound="ZoneInfo")
@@ -16,14 +16,14 @@ class ZoneInfo(tzinfo):
@classmethod
def no_cache(cls: Type[_T], key: str) -> _T: ...
@classmethod
def from_file(cls: Type[_T], __fobj: _IOBytes, key: Optional[str] = ...) -> _T: ...
def from_file(cls: Type[_T], __fobj: _IOBytes, key: str | None = ...) -> _T: ...
@classmethod
def clear_cache(cls, *, only_keys: Iterable[str] = ...) -> None: ...
# Note: Both here and in clear_cache, the types allow the use of `str` where
# a sequence of strings is required. This should be remedied if a solution
# to this typing bug is found: https://github.com/python/typing/issues/256
def reset_tzpath(to: Optional[Sequence[StrPath]] = ...) -> None: ...
def reset_tzpath(to: Sequence[StrPath] | None = ...) -> None: ...
def available_timezones() -> Set[str]: ...
TZPATH: Sequence[str]