Sync vendored typeshed stubs (#12116)

This commit is contained in:
github-actions[bot] 2024-07-01 07:07:45 +01:00 committed by GitHub
parent d1aeadc009
commit db6ee74cbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 417 additions and 230 deletions

View file

@ -1 +1 @@
114409d49b43ba62a179ebb856fa70a5161f751e
dcab6e88883c629ede9637fb011958f8b4918f52

View file

@ -34,6 +34,7 @@ _dummy_thread: 3.0-3.8
_dummy_threading: 3.0-3.8
_heapq: 3.0-
_imp: 3.0-
_interpchannels: 3.13-
_json: 3.0-
_locale: 3.0-
_lsprof: 3.0-

View file

@ -0,0 +1,84 @@
from _typeshed import structseq
from typing import Final, Literal, SupportsIndex, final
from typing_extensions import Buffer, Self
class ChannelError(RuntimeError): ...
class ChannelClosedError(ChannelError): ...
class ChannelEmptyError(ChannelError): ...
class ChannelNotEmptyError(ChannelError): ...
class ChannelNotFoundError(ChannelError): ...
# Mark as final, since instantiating ChannelID is not supported.
@final
class ChannelID:
@property
def end(self) -> Literal["send", "recv", "both"]: ...
@property
def send(self) -> Self: ...
@property
def recv(self) -> Self: ...
def __eq__(self, other: object) -> bool: ...
def __ge__(self, other: ChannelID) -> bool: ...
def __gt__(self, other: ChannelID) -> bool: ...
def __hash__(self) -> int: ...
def __index__(self) -> int: ...
def __int__(self) -> int: ...
def __le__(self, other: ChannelID) -> bool: ...
def __lt__(self, other: ChannelID) -> bool: ...
def __ne__(self, other: object) -> bool: ...
@final
class ChannelInfo(structseq[int], tuple[bool, bool, bool, int, int, int, int, int]):
__match_args__: Final = (
"open",
"closing",
"closed",
"count",
"num_interp_send",
"num_interp_send_released",
"num_interp_recv",
"num_interp_recv_released",
)
@property
def open(self) -> bool: ...
@property
def closing(self) -> bool: ...
@property
def closed(self) -> bool: ...
@property
def count(self) -> int: ... # type: ignore[override]
@property
def num_interp_send(self) -> int: ...
@property
def num_interp_send_released(self) -> int: ...
@property
def num_interp_recv(self) -> int: ...
@property
def num_interp_recv_released(self) -> int: ...
@property
def num_interp_both(self) -> int: ...
@property
def num_interp_both_recv_released(self) -> int: ...
@property
def num_interp_both_send_released(self) -> int: ...
@property
def num_interp_both_released(self) -> int: ...
@property
def recv_associated(self) -> bool: ...
@property
def recv_released(self) -> bool: ...
@property
def send_associated(self) -> bool: ...
@property
def send_released(self) -> bool: ...
def create() -> ChannelID: ...
def destroy(cid: SupportsIndex) -> None: ...
def list_all() -> list[ChannelID]: ...
def list_interpreters(cid: SupportsIndex, *, send: bool) -> list[int]: ...
def send(cid: SupportsIndex, obj: object, *, blocking: bool = True, timeout: float | None = None) -> None: ...
def send_buffer(cid: SupportsIndex, obj: Buffer, *, blocking: bool = True, timeout: float | None = None) -> None: ...
def recv(cid: SupportsIndex, default: object = ...) -> object: ...
def close(cid: SupportsIndex, *, send: bool = False, recv: bool = False) -> None: ...
def get_info(cid: SupportsIndex) -> ChannelInfo: ...
def release(cid: SupportsIndex, *, send: bool = False, recv: bool = False, force: bool = False) -> None: ...

View file

@ -21,8 +21,9 @@ class ProxyType(Generic[_T]): # "weakproxy"
def __getattr__(self, attr: str) -> Any: ...
class ReferenceType(Generic[_T]):
__callback__: Callable[[ReferenceType[_T]], Any]
def __new__(cls, o: _T, callback: Callable[[ReferenceType[_T]], Any] | None = ..., /) -> Self: ...
__callback__: Callable[[Self], Any]
def __new__(cls, o: _T, callback: Callable[[Self], Any] | None = ..., /) -> Self: ...
def __init__(self, o: _T, callback: Callable[[Self], Any] | None = ..., /) -> None: ...
def __call__(self) -> _T | None: ...
def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ...

View file

@ -32,6 +32,7 @@ _T = TypeVar("_T")
_ActionT = TypeVar("_ActionT", bound=Action)
_ArgumentParserT = TypeVar("_ArgumentParserT", bound=ArgumentParser)
_N = TypeVar("_N")
_ActionType: TypeAlias = Callable[[str], Any] | FileType | str
# more precisely, Literal["store", "store_const", "store_true",
# "store_false", "append", "append_const", "count", "help", "version",
# "extend"], but using this would make it hard to annotate callers
@ -89,7 +90,7 @@ class _ActionsContainer:
nargs: int | _NArgsStr | _SUPPRESS_T | None = None,
const: Any = ...,
default: Any = ...,
type: Callable[[str], _T] | FileType = ...,
type: _ActionType = ...,
choices: Iterable[_T] | None = ...,
required: bool = ...,
help: str | None = ...,
@ -313,7 +314,7 @@ class Action(_AttributeHolder):
nargs: int | str | None
const: Any
default: Any
type: Callable[[str], Any] | FileType | None
type: _ActionType | None
choices: Iterable[Any] | None
required: bool
help: str | None
@ -699,6 +700,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
add_help: bool = ...,
allow_abbrev: bool = ...,
exit_on_error: bool = ...,
**kwargs: Any, # Accepting any additional kwargs for custom parser classes
) -> _ArgumentParserT: ...
elif sys.version_info >= (3, 9):
def add_parser(
@ -721,6 +723,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
add_help: bool = ...,
allow_abbrev: bool = ...,
exit_on_error: bool = ...,
**kwargs: Any, # Accepting any additional kwargs for custom parser classes
) -> _ArgumentParserT: ...
else:
def add_parser(
@ -742,6 +745,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
conflict_handler: str = ...,
add_help: bool = ...,
allow_abbrev: bool = ...,
**kwargs: Any, # Accepting any additional kwargs for custom parser classes
) -> _ArgumentParserT: ...
def _get_subactions(self) -> list[Action]: ...

View file

@ -16,7 +16,24 @@ from .tasks import Task
from .transports import BaseTransport, DatagramTransport, ReadTransport, SubprocessTransport, Transport, WriteTransport
from .unix_events import AbstractChildWatcher
__all__ = (
if sys.version_info >= (3, 14):
__all__ = (
"AbstractEventLoopPolicy",
"AbstractEventLoop",
"AbstractServer",
"Handle",
"TimerHandle",
"get_event_loop_policy",
"set_event_loop_policy",
"get_event_loop",
"set_event_loop",
"new_event_loop",
"_set_running_loop",
"get_running_loop",
"_get_running_loop",
)
else:
__all__ = (
"AbstractEventLoopPolicy",
"AbstractEventLoop",
"AbstractServer",
@ -32,7 +49,7 @@ __all__ = (
"_set_running_loop",
"get_running_loop",
"_get_running_loop",
)
)
_T = TypeVar("_T")
_Ts = TypeVarTuple("_Ts")
@ -541,6 +558,7 @@ class AbstractEventLoopPolicy:
@abstractmethod
def new_event_loop(self) -> AbstractEventLoop: ...
# Child processes handling (Unix only).
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
@abstractmethod
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
@ -565,13 +583,14 @@ def get_event_loop() -> AbstractEventLoop: ...
def set_event_loop(loop: AbstractEventLoop | None) -> None: ...
def new_event_loop() -> AbstractEventLoop: ...
if sys.version_info >= (3, 12):
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
def get_child_watcher() -> AbstractChildWatcher: ...
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
else:
else:
def get_child_watcher() -> AbstractChildWatcher: ...
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...

View file

@ -70,7 +70,10 @@ _T4 = TypeVar("_T4")
_T5 = TypeVar("_T5")
_T6 = TypeVar("_T6")
_FT = TypeVar("_FT", bound=Future[Any])
_FutureLike: TypeAlias = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
if sys.version_info >= (3, 12):
_FutureLike: TypeAlias = Future[_T] | Awaitable[_T]
else:
_FutureLike: TypeAlias = Future[_T] | Generator[Any, None, _T] | Awaitable[_T]
_TaskYieldType: TypeAlias = Future[object] | None
FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED

View file

@ -13,7 +13,8 @@ _Ts = TypeVarTuple("_Ts")
# This is also technically not available on Win,
# but other parts of typeshed need this definition.
# So, it is special cased.
if sys.version_info >= (3, 12):
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
class AbstractChildWatcher:
@abstractmethod
@ -35,7 +36,7 @@ if sys.version_info >= (3, 12):
@abstractmethod
def is_active(self) -> bool: ...
else:
else:
class AbstractChildWatcher:
@abstractmethod
def add_child_handler(
@ -57,7 +58,9 @@ else:
def is_active(self) -> bool: ...
if sys.platform != "win32":
if sys.version_info >= (3, 9):
if sys.version_info >= (3, 14):
__all__ = ("SelectorEventLoop", "DefaultEventLoopPolicy")
elif sys.version_info >= (3, 9):
__all__ = (
"SelectorEventLoop",
"AbstractChildWatcher",
@ -79,6 +82,8 @@ if sys.platform != "win32":
"DefaultEventLoopPolicy",
)
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
# Doesn't actually have ABCMeta metaclass at runtime, but mypy complains if we don't have it in the stub.
# See discussion in #7412
class BaseChildWatcher(AbstractChildWatcher, metaclass=ABCMeta):
@ -86,11 +91,12 @@ if sys.platform != "win32":
def is_active(self) -> bool: ...
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
if sys.version_info >= (3, 12):
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
class SafeChildWatcher(BaseChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
def __exit__(
self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None
) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
@ -99,16 +105,27 @@ if sys.platform != "win32":
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
class FastChildWatcher(BaseChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
def __exit__(
self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None
) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
def remove_child_handler(self, pid: int) -> bool: ...
else:
# Doesn't actually have ABCMeta metaclass at runtime, but mypy complains if we don't have it in the stub.
# See discussion in #7412
class BaseChildWatcher(AbstractChildWatcher, metaclass=ABCMeta):
def close(self) -> None: ...
def is_active(self) -> bool: ...
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
class SafeChildWatcher(BaseChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
def __exit__(
self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None
) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
@ -116,7 +133,9 @@ if sys.platform != "win32":
class FastChildWatcher(BaseChildWatcher):
def __enter__(self) -> Self: ...
def __exit__(self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None) -> None: ...
def __exit__(
self, a: type[BaseException] | None, b: BaseException | None, c: types.TracebackType | None
) -> None: ...
def add_child_handler(
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
) -> None: ...
@ -125,6 +144,7 @@ if sys.platform != "win32":
class _UnixSelectorEventLoop(BaseSelectorEventLoop): ...
class _UnixDefaultEventLoopPolicy(BaseDefaultEventLoopPolicy):
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
def get_child_watcher(self) -> AbstractChildWatcher: ...
@ -138,6 +158,7 @@ if sys.platform != "win32":
DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy
if sys.version_info < (3, 14):
if sys.version_info >= (3, 12):
@deprecated("Deprecated as of Python 3.12; will be removed in Python 3.14")
class MultiLoopChildWatcher(AbstractChildWatcher):
@ -167,6 +188,7 @@ if sys.platform != "win32":
def remove_child_handler(self, pid: int) -> bool: ...
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
if sys.version_info < (3, 14):
class ThreadedChildWatcher(AbstractChildWatcher):
def is_active(self) -> Literal[True]: ...
def close(self) -> None: ...

View file

@ -74,6 +74,7 @@ if sys.platform == "win32":
class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
_loop_factory: ClassVar[type[SelectorEventLoop]]
if sys.version_info < (3, 14):
def get_child_watcher(self) -> NoReturn: ...
def set_child_watcher(self, watcher: Any) -> NoReturn: ...

View file

@ -1673,9 +1673,9 @@ def pow(base: float, exp: complex | _SupportsSomeKindOfPow, mod: None = None) ->
@overload
def pow(base: complex, exp: complex | _SupportsSomeKindOfPow, mod: None = None) -> complex: ...
@overload
def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ...
def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
@overload
def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ...
def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap]
@overload
def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M) -> _T_co: ...
@overload

View file

@ -108,7 +108,7 @@ class _DefaultFactory(Protocol[_T_co]):
class Field(Generic[_T]):
name: str
type: Type[_T]
type: Type[_T] | str | Any
default: _T | Literal[_MISSING_TYPE.MISSING]
default_factory: _DefaultFactory[_T] | Literal[_MISSING_TYPE.MISSING]
repr: bool

View file

@ -8,7 +8,7 @@ from string import Template
from time import struct_time
from types import FrameType, TracebackType
from typing import Any, ClassVar, Generic, Literal, Protocol, TextIO, TypeVar, overload
from typing_extensions import Self, TypeAlias
from typing_extensions import Self, TypeAlias, deprecated
if sys.version_info >= (3, 11):
from types import GenericAlias
@ -574,11 +574,8 @@ def disable(level: int = 50) -> None: ...
def addLevelName(level: int, levelName: str) -> None: ...
@overload
def getLevelName(level: int) -> str: ...
# The str -> int case is considered a mistake, but retained for backward
# compatibility. See
# https://docs.python.org/3/library/logging.html#logging.getLevelName.
@overload
@deprecated("The str -> int case is considered a mistake.")
def getLevelName(level: str) -> Any: ...
if sys.version_info >= (3, 11):

View file

@ -92,17 +92,21 @@ class BaseContext:
@overload
def Value(self, typecode_or_type: str | type[_CData], *args: Any, lock: bool | _LockLike = True) -> Any: ...
@overload
def Array(
self, typecode_or_type: type[_SimpleCData[_T]], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]
) -> SynchronizedArray[_T]: ...
@overload
def Array(
self, typecode_or_type: type[c_char], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = True
) -> SynchronizedString: ...
@overload
def Array(
self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[False]
) -> SynchronizedArray[_CT]: ...
@overload
def Array(
self, typecode_or_type: type[_CT], size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = True
) -> SynchronizedArray[_CT]: ...
self,
typecode_or_type: type[_SimpleCData[_T]],
size_or_initializer: int | Sequence[Any],
*,
lock: Literal[True] | _LockLike = True,
) -> SynchronizedArray[_T]: ...
@overload
def Array(
self, typecode_or_type: str, size_or_initializer: int | Sequence[Any], *, lock: Literal[True] | _LockLike = True

View file

@ -39,12 +39,20 @@ def Array(
) -> _CT: ...
@overload
def Array(
typecode_or_type: type[_CT],
typecode_or_type: type[c_char],
size_or_initializer: int | Sequence[Any],
*,
lock: Literal[True] | _LockLike = True,
ctx: BaseContext | None = None,
) -> SynchronizedArray[_CT]: ...
) -> SynchronizedString: ...
@overload
def Array(
typecode_or_type: type[_SimpleCData[_T]],
size_or_initializer: int | Sequence[Any],
*,
lock: Literal[True] | _LockLike = True,
ctx: BaseContext | None = None,
) -> SynchronizedArray[_T]: ...
@overload
def Array(
typecode_or_type: str,
@ -65,9 +73,11 @@ def copy(obj: _CT) -> _CT: ...
@overload
def synchronized(obj: _SimpleCData[_T], lock: _LockLike | None = None, ctx: Any | None = None) -> Synchronized[_T]: ...
@overload
def synchronized(obj: ctypes.Array[c_char], lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedString: ...
def synchronized(obj: ctypes.Array[c_char], lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedString: ... # type: ignore
@overload
def synchronized(obj: ctypes.Array[_CT], lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedArray[_CT]: ...
def synchronized(
obj: ctypes.Array[_SimpleCData[_T]], lock: _LockLike | None = None, ctx: Any | None = None
) -> SynchronizedArray[_T]: ...
@overload
def synchronized(obj: _CT, lock: _LockLike | None = None, ctx: Any | None = None) -> SynchronizedBase[_CT]: ...
@ -89,19 +99,30 @@ class SynchronizedBase(Generic[_CT]):
class Synchronized(SynchronizedBase[_SimpleCData[_T]], Generic[_T]):
value: _T
class SynchronizedArray(SynchronizedBase[ctypes.Array[_CT]], Generic[_CT]):
class SynchronizedArray(SynchronizedBase[ctypes.Array[_SimpleCData[_T]]], Generic[_T]):
def __len__(self) -> int: ...
@overload
def __getitem__(self, i: slice) -> list[_CT]: ...
def __getitem__(self, i: slice) -> list[_T]: ...
@overload
def __getitem__(self, i: int) -> _CT: ...
def __getitem__(self, i: int) -> _T: ...
@overload
def __setitem__(self, i: slice, value: Iterable[_CT]) -> None: ...
def __setitem__(self, i: slice, value: Iterable[_T]) -> None: ...
@overload
def __setitem__(self, i: int, value: _CT) -> None: ...
def __getslice__(self, start: int, stop: int) -> list[_CT]: ...
def __setslice__(self, start: int, stop: int, values: Iterable[_CT]) -> None: ...
def __setitem__(self, i: int, value: _T) -> None: ...
def __getslice__(self, start: int, stop: int) -> list[_T]: ...
def __setslice__(self, start: int, stop: int, values: Iterable[_T]) -> None: ...
class SynchronizedString(SynchronizedArray[bytes]):
@overload # type: ignore[override]
def __getitem__(self, i: slice) -> bytes: ...
@overload # type: ignore[override]
def __getitem__(self, i: int) -> bytes: ...
@overload # type: ignore[override]
def __setitem__(self, i: slice, value: bytes) -> None: ...
@overload # type: ignore[override]
def __setitem__(self, i: int, value: bytes) -> None: ... # type: ignore[override]
def __getslice__(self, start: int, stop: int) -> bytes: ... # type: ignore[override]
def __setslice__(self, start: int, stop: int, values: bytes) -> None: ... # type: ignore[override]
class SynchronizedString(SynchronizedArray[c_char]):
value: bytes
raw: bytes

View file

@ -914,8 +914,8 @@ if sys.platform != "win32":
def forkpty() -> tuple[int, int]: ... # some flavors of Unix
def killpg(pgid: int, signal: int, /) -> None: ...
def nice(increment: int, /) -> int: ...
if sys.platform != "darwin":
def plock(op: int, /) -> None: ... # ???op is int?
if sys.platform != "darwin" and sys.platform != "linux":
def plock(op: int, /) -> None: ...
class _wrap_close(_TextIOWrapper):
def __init__(self, stream: _TextIOWrapper, proc: Popen[str]) -> None: ...
@ -1141,16 +1141,16 @@ if sys.version_info >= (3, 10) and sys.platform == "linux":
if sys.version_info >= (3, 12) and sys.platform == "linux":
CLONE_FILES: int
CLONE_FS: int
CLONE_NEWCGROUP: int
CLONE_NEWIPC: int
CLONE_NEWNET: int
CLONE_NEWCGROUP: int # Linux 4.6+
CLONE_NEWIPC: int # Linux 2.6.19+
CLONE_NEWNET: int # Linux 2.6.24+
CLONE_NEWNS: int
CLONE_NEWPID: int
CLONE_NEWTIME: int
CLONE_NEWUSER: int
CLONE_NEWUTS: int
CLONE_NEWPID: int # Linux 3.8+
CLONE_NEWTIME: int # Linux 5.6+
CLONE_NEWUSER: int # Linux 3.8+
CLONE_NEWUTS: int # Linux 2.6.19+
CLONE_SIGHAND: int
CLONE_SYSVSEM: int
CLONE_SYSVSEM: int # Linux 2.6.26+
CLONE_THREAD: int
CLONE_VM: int
def unshare(flags: int) -> None: ...

View file

@ -77,11 +77,7 @@ pathsep: LiteralString
defpath: LiteralString
devnull: LiteralString
# Overloads are necessary to work around python/mypy#3644.
@overload
def abspath(path: PathLike[AnyStr]) -> AnyStr: ...
@overload
def abspath(path: AnyStr) -> AnyStr: ...
def abspath(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
@overload
def basename(p: PathLike[AnyStr]) -> AnyStr: ...
@overload
@ -90,14 +86,8 @@ def basename(p: AnyOrLiteralStr) -> AnyOrLiteralStr: ...
def dirname(p: PathLike[AnyStr]) -> AnyStr: ...
@overload
def dirname(p: AnyOrLiteralStr) -> AnyOrLiteralStr: ...
@overload
def expanduser(path: PathLike[AnyStr]) -> AnyStr: ...
@overload
def expanduser(path: AnyStr) -> AnyStr: ...
@overload
def expandvars(path: PathLike[AnyStr]) -> AnyStr: ...
@overload
def expandvars(path: AnyStr) -> AnyStr: ...
def expanduser(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
def expandvars(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ...
@overload
def normcase(s: PathLike[AnyStr]) -> AnyStr: ...
@overload

View file

@ -36,6 +36,11 @@ if sys.platform != "win32":
def sp_expire(self) -> int: ...
@property
def sp_flag(self) -> int: ...
# Deprecated aliases below.
@property
def sp_nam(self) -> str: ...
@property
def sp_pwd(self) -> str: ...
def getspall() -> list[struct_spwd]: ...
def getspnam(arg: str, /) -> struct_spwd: ...

View file

@ -889,6 +889,7 @@ if sys.version_info >= (3, 11):
start_new_session: bool = False,
pass_fds: Collection[int] = ...,
*,
encoding: str | None = None,
timeout: float | None = None,
text: bool | None = None,
user: str | int | None = None,
@ -920,6 +921,7 @@ elif sys.version_info >= (3, 10):
start_new_session: bool = False,
pass_fds: Collection[int] = ...,
*,
encoding: str | None = None,
timeout: float | None = None,
text: bool | None = None,
user: str | int | None = None,
@ -950,6 +952,7 @@ elif sys.version_info >= (3, 9):
start_new_session: bool = False,
pass_fds: Collection[int] = ...,
*,
encoding: str | None = None,
timeout: float | None = None,
text: bool | None = None,
user: str | int | None = None,
@ -978,6 +981,7 @@ else:
start_new_session: bool = False,
pass_fds: Collection[int] = ...,
*,
encoding: str | None = None,
timeout: float | None = None,
text: bool | None = None,
) -> int: ...
@ -1005,6 +1009,7 @@ if sys.version_info >= (3, 11):
pass_fds: Collection[int] = ...,
timeout: float | None = ...,
*,
encoding: str | None = None,
text: bool | None = None,
user: str | int | None = None,
group: str | int | None = None,
@ -1036,6 +1041,7 @@ elif sys.version_info >= (3, 10):
pass_fds: Collection[int] = ...,
timeout: float | None = ...,
*,
encoding: str | None = None,
text: bool | None = None,
user: str | int | None = None,
group: str | int | None = None,
@ -1066,6 +1072,7 @@ elif sys.version_info >= (3, 9):
pass_fds: Collection[int] = ...,
timeout: float | None = ...,
*,
encoding: str | None = None,
text: bool | None = None,
user: str | int | None = None,
group: str | int | None = None,
@ -1094,6 +1101,7 @@ else:
pass_fds: Collection[int] = ...,
timeout: float | None = ...,
*,
encoding: str | None = None,
text: bool | None = None,
) -> int: ...

View file

@ -103,10 +103,13 @@ PAX_NAME_FIELDS: set[str]
ENCODING: str
_FileCreationModes: TypeAlias = Literal["a", "w", "x"]
@overload
def open(
name: StrOrBytesPath | None = None,
mode: str = "r",
fileobj: IO[bytes] | None = None, # depends on mode
fileobj: IO[bytes] | None = None,
bufsize: int = 10240,
*,
format: int | None = ...,
@ -121,6 +124,25 @@ def open(
compresslevel: int | None = ...,
preset: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | None = ...,
) -> TarFile: ...
@overload
def open(
name: StrOrBytesPath | None = None,
mode: _FileCreationModes = ...,
fileobj: _Fileobj | None = None,
bufsize: int = 10240,
*,
format: int | None = ...,
tarinfo: type[TarInfo] | None = ...,
dereference: bool | None = ...,
ignore_zeros: bool | None = ...,
encoding: str | None = ...,
errors: str = ...,
pax_headers: Mapping[str, str] | None = ...,
debug: int | None = ...,
errorlevel: int | None = ...,
compresslevel: int | None = ...,
preset: int | None = ...,
) -> TarFile: ...
class ExFileObject(io.BufferedReader):
def __init__(self, tarfile: TarFile, tarinfo: TarInfo) -> None: ...

View file

@ -41,7 +41,10 @@ _P = ParamSpec("_P")
ProxyTypes: tuple[type[Any], ...]
class WeakMethod(ref[_CallableT]):
def __new__(cls, meth: _CallableT, callback: Callable[[Self], object] | None = None) -> Self: ...
# `ref` is implemented in `C` so positional-only arguments are enforced, but not in `WeakMethod`.
def __new__( # pyright: ignore[reportInconsistentConstructor]
cls, meth: _CallableT, callback: Callable[[Self], Any] | None = None
) -> Self: ...
def __call__(self) -> _CallableT | None: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...

View file

@ -14,7 +14,7 @@ class ContentHandler:
def startDocument(self) -> None: ...
def endDocument(self) -> None: ...
def startPrefixMapping(self, prefix: str | None, uri: str) -> None: ...
def endPrefixMapping(self, prefix) -> None: ...
def endPrefixMapping(self, prefix: str | None) -> None: ...
def startElement(self, name: str, attrs: xmlreader.AttributesImpl) -> None: ...
def endElement(self, name: str) -> None: ...
def startElementNS(self, name: tuple[str, str], qname: str, attrs: xmlreader.AttributesNSImpl) -> None: ...

View file

@ -28,5 +28,7 @@ class zipimporter:
def is_package(self, fullname: str) -> bool: ...
def load_module(self, fullname: str) -> ModuleType: ...
if sys.version_info >= (3, 10):
def exec_module(self, module: ModuleType) -> None: ...
def create_module(self, spec: ModuleSpec) -> None: ...
def find_spec(self, fullname: str, target: ModuleType | None = None) -> ModuleSpec | None: ...
def invalidate_caches(self) -> None: ...