Sync vendored typeshed stubs (#17402)

Close and reopen this PR to trigger CI

---------

Co-authored-by: typeshedbot <>
Co-authored-by: David Peter <mail@david-peter.de>
This commit is contained in:
github-actions[bot] 2025-04-15 09:16:42 +02:00 committed by GitHub
parent 3b24fe5c07
commit 4894f52bae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
146 changed files with 1520 additions and 3323 deletions

View File

@ -421,16 +421,16 @@ mod tests {
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r###" assert_snapshot!(test.goto_type_definition(), @r#"
info: lint:goto-type-definition: Type definition info: lint:goto-type-definition: Type definition
--> stdlib/builtins.pyi:443:7 --> stdlib/builtins.pyi:438:7
| |
441 | def __getitem__(self, key: int, /) -> str | int | None: ... 436 | def __getitem__(self, key: int, /) -> str | int | None: ...
442 | 437 |
443 | class str(Sequence[str]): 438 | class str(Sequence[str]):
| ^^^ | ^^^
444 | @overload 439 | @overload
445 | def __new__(cls, object: object = ...) -> Self: ... 440 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> /main.py:4:13 --> /main.py:4:13
@ -440,7 +440,7 @@ mod tests {
4 | a 4 | a
| ^ | ^
| |
"###); "#);
} }
#[test] #[test]
fn goto_type_of_expression_with_literal_node() { fn goto_type_of_expression_with_literal_node() {
@ -450,16 +450,16 @@ mod tests {
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r###" assert_snapshot!(test.goto_type_definition(), @r#"
info: lint:goto-type-definition: Type definition info: lint:goto-type-definition: Type definition
--> stdlib/builtins.pyi:443:7 --> stdlib/builtins.pyi:438:7
| |
441 | def __getitem__(self, key: int, /) -> str | int | None: ... 436 | def __getitem__(self, key: int, /) -> str | int | None: ...
442 | 437 |
443 | class str(Sequence[str]): 438 | class str(Sequence[str]):
| ^^^ | ^^^
444 | @overload 439 | @overload
445 | def __new__(cls, object: object = ...) -> Self: ... 440 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> /main.py:2:22 --> /main.py:2:22
@ -467,7 +467,7 @@ mod tests {
2 | a: str = "test" 2 | a: str = "test"
| ^^^^^^ | ^^^^^^
| |
"###); "#);
} }
#[test] #[test]
@ -532,16 +532,16 @@ mod tests {
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r###" assert_snapshot!(test.goto_type_definition(), @r#"
info: lint:goto-type-definition: Type definition info: lint:goto-type-definition: Type definition
--> stdlib/builtins.pyi:443:7 --> stdlib/builtins.pyi:438:7
| |
441 | def __getitem__(self, key: int, /) -> str | int | None: ... 436 | def __getitem__(self, key: int, /) -> str | int | None: ...
442 | 437 |
443 | class str(Sequence[str]): 438 | class str(Sequence[str]):
| ^^^ | ^^^
444 | @overload 439 | @overload
445 | def __new__(cls, object: object = ...) -> Self: ... 440 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> /main.py:4:18 --> /main.py:4:18
@ -551,7 +551,7 @@ mod tests {
4 | test(a= "123") 4 | test(a= "123")
| ^ | ^
| |
"###); "#);
} }
#[test] #[test]
@ -567,16 +567,16 @@ mod tests {
// TODO: This should jump to `str` and not `int` because // TODO: This should jump to `str` and not `int` because
// the keyword is typed as a string. It's only the passed argument that // the keyword is typed as a string. It's only the passed argument that
// is an int. Navigating to `str` would match pyright's behavior. // is an int. Navigating to `str` would match pyright's behavior.
assert_snapshot!(test.goto_type_definition(), @r###" assert_snapshot!(test.goto_type_definition(), @r"
info: lint:goto-type-definition: Type definition info: lint:goto-type-definition: Type definition
--> stdlib/builtins.pyi:234:7 --> stdlib/builtins.pyi:231:7
| |
232 | _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed 229 | _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026 # TODO: Use TypeAlias once mypy bugs are fixed
233 | 230 |
234 | class int: 231 | class int:
| ^^^ | ^^^
235 | @overload 232 | @overload
236 | def __new__(cls, x: ConvertibleToInt = ..., /) -> Self: ... 233 | def __new__(cls, x: ConvertibleToInt = ..., /) -> Self: ...
| |
info: Source info: Source
--> /main.py:4:18 --> /main.py:4:18
@ -586,7 +586,7 @@ mod tests {
4 | test(a= 123) 4 | test(a= 123)
| ^ | ^
| |
"###); ");
} }
#[test] #[test]
@ -601,16 +601,16 @@ f(**kwargs<CURSOR>)
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r###" assert_snapshot!(test.goto_type_definition(), @r#"
info: lint:goto-type-definition: Type definition info: lint:goto-type-definition: Type definition
--> stdlib/builtins.pyi:1098:7 --> stdlib/builtins.pyi:1086:7
| |
1096 | def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... 1084 | def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
1097 | 1085 |
1098 | class dict(MutableMapping[_KT, _VT]): 1086 | class dict(MutableMapping[_KT, _VT]):
| ^^^^ | ^^^^
1099 | # __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics 1087 | # __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics
1100 | # Also multiprocessing.managers.SyncManager.dict() 1088 | # Also multiprocessing.managers.SyncManager.dict()
| |
info: Source info: Source
--> /main.py:6:5 --> /main.py:6:5
@ -620,7 +620,7 @@ f(**kwargs<CURSOR>)
6 | f(**kwargs) 6 | f(**kwargs)
| ^^^^^^ | ^^^^^^
| |
"###); "#);
} }
#[test] #[test]
@ -632,16 +632,16 @@ f(**kwargs<CURSOR>)
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r###" assert_snapshot!(test.goto_type_definition(), @r"
info: lint:goto-type-definition: Type definition info: lint:goto-type-definition: Type definition
--> stdlib/builtins.pyi:443:7 --> stdlib/builtins.pyi:438:7
| |
441 | def __getitem__(self, key: int, /) -> str | int | None: ... 436 | def __getitem__(self, key: int, /) -> str | int | None: ...
442 | 437 |
443 | class str(Sequence[str]): 438 | class str(Sequence[str]):
| ^^^ | ^^^
444 | @overload 439 | @overload
445 | def __new__(cls, object: object = ...) -> Self: ... 440 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> /main.py:3:17 --> /main.py:3:17
@ -650,7 +650,7 @@ f(**kwargs<CURSOR>)
3 | a 3 | a
| ^ | ^
| |
"###); ");
} }
#[test] #[test]
@ -725,16 +725,16 @@ f(**kwargs<CURSOR>)
"#, "#,
); );
assert_snapshot!(test.goto_type_definition(), @r###" assert_snapshot!(test.goto_type_definition(), @r"
info: lint:goto-type-definition: Type definition info: lint:goto-type-definition: Type definition
--> stdlib/builtins.pyi:443:7 --> stdlib/builtins.pyi:438:7
| |
441 | def __getitem__(self, key: int, /) -> str | int | None: ... 436 | def __getitem__(self, key: int, /) -> str | int | None: ...
442 | 437 |
443 | class str(Sequence[str]): 438 | class str(Sequence[str]):
| ^^^ | ^^^
444 | @overload 439 | @overload
445 | def __new__(cls, object: object = ...) -> Self: ... 440 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> /main.py:4:27 --> /main.py:4:27
@ -744,7 +744,7 @@ f(**kwargs<CURSOR>)
4 | print(a) 4 | print(a)
| ^ | ^
| |
"###); ");
} }
#[test] #[test]
@ -758,13 +758,13 @@ f(**kwargs<CURSOR>)
assert_snapshot!(test.goto_type_definition(), @r" assert_snapshot!(test.goto_type_definition(), @r"
info: lint:goto-type-definition: Type definition info: lint:goto-type-definition: Type definition
--> stdlib/types.pyi:677:11 --> stdlib/types.pyi:671:11
| |
675 | if sys.version_info >= (3, 10): 669 | if sys.version_info >= (3, 10):
676 | @final 670 | @final
677 | class NoneType: 671 | class NoneType:
| ^^^^^^^^ | ^^^^^^^^
678 | def __bool__(self) -> Literal[False]: ... 672 | def __bool__(self) -> Literal[False]: ...
| |
info: Source info: Source
--> /main.py:3:17 --> /main.py:3:17
@ -775,14 +775,14 @@ f(**kwargs<CURSOR>)
| |
info: lint:goto-type-definition: Type definition info: lint:goto-type-definition: Type definition
--> stdlib/builtins.pyi:443:7 --> stdlib/builtins.pyi:438:7
| |
441 | def __getitem__(self, key: int, /) -> str | int | None: ... 436 | def __getitem__(self, key: int, /) -> str | int | None: ...
442 | 437 |
443 | class str(Sequence[str]): 438 | class str(Sequence[str]):
| ^^^ | ^^^
444 | @overload 439 | @overload
445 | def __new__(cls, object: object = ...) -> Self: ... 440 | def __new__(cls, object: object = ...) -> Self: ...
| |
info: Source info: Source
--> /main.py:3:17 --> /main.py:3:17

View File

@ -19,7 +19,7 @@ it before submitting pull requests; do not report issues with annotations to
the project the stubs are for, but instead report them here to typeshed.** the project the stubs are for, but instead report them here to typeshed.**
Further documentation on stub files, typeshed, and Python's typing system in Further documentation on stub files, typeshed, and Python's typing system in
general, can also be found at https://typing.python.org/en/latest/. general, can also be found at https://typing.readthedocs.io/en/latest/.
Typeshed supports Python versions 3.9 to 3.13. Typeshed supports Python versions 3.9 to 3.13.

View File

@ -1 +1 @@
bfd032156c59bbf851f62174014f24f4f89b96af f65bdc1acde54fda93c802459280da74518d2eef

View File

@ -36,8 +36,6 @@ _curses: 3.0-
_curses_panel: 3.0- _curses_panel: 3.0-
_dbm: 3.0- _dbm: 3.0-
_decimal: 3.3- _decimal: 3.3-
_dummy_thread: 3.0-3.8
_dummy_threading: 3.0-3.8
_frozen_importlib: 3.0- _frozen_importlib: 3.0-
_frozen_importlib_external: 3.5- _frozen_importlib_external: 3.5-
_gdbm: 3.0- _gdbm: 3.0-
@ -140,7 +138,6 @@ distutils: 3.0-3.11
distutils.command.bdist_msi: 3.0-3.10 distutils.command.bdist_msi: 3.0-3.10
distutils.command.bdist_wininst: 3.0-3.9 distutils.command.bdist_wininst: 3.0-3.9
doctest: 3.0- doctest: 3.0-
dummy_threading: 3.0-3.8
email: 3.0- email: 3.0-
encodings: 3.0- encodings: 3.0-
encodings.cp1125: 3.4- encodings.cp1125: 3.4-
@ -148,7 +145,6 @@ encodings.cp273: 3.4-
encodings.cp858: 3.2- encodings.cp858: 3.2-
encodings.koi8_t: 3.5- encodings.koi8_t: 3.5-
encodings.kz1048: 3.5- encodings.kz1048: 3.5-
encodings.mac_centeuro: 3.0-3.8
ensurepip: 3.0- ensurepip: 3.0-
enum: 3.4- enum: 3.4-
errno: 3.0- errno: 3.0-

View File

@ -130,17 +130,6 @@ if sys.version_info >= (3, 10):
pattern as pattern, pattern as pattern,
) )
if sys.version_info < (3, 9):
from ast import (
AugLoad as AugLoad,
AugStore as AugStore,
ExtSlice as ExtSlice,
Index as Index,
Param as Param,
Suite as Suite,
slice as slice,
)
PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192] PyCF_ALLOW_TOP_LEVEL_AWAIT: Literal[8192]
PyCF_ONLY_AST: Literal[1024] PyCF_ONLY_AST: Literal[1024]
PyCF_TYPE_COMMENTS: Literal[4096] PyCF_TYPE_COMMENTS: Literal[4096]

View File

@ -2,13 +2,10 @@ import sys
from asyncio.events import AbstractEventLoop from asyncio.events import AbstractEventLoop
from collections.abc import Awaitable, Callable, Coroutine, Generator from collections.abc import Awaitable, Callable, Coroutine, Generator
from contextvars import Context from contextvars import Context
from types import FrameType from types import FrameType, GenericAlias
from typing import Any, Literal, TextIO, TypeVar from typing import Any, Literal, TextIO, TypeVar
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T") _T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True) _T_co = TypeVar("_T_co", covariant=True)
_TaskYieldType: TypeAlias = Future[object] | None _TaskYieldType: TypeAlias = Future[object] | None
@ -29,11 +26,7 @@ class Future(Awaitable[_T]):
@property @property
def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ... def _callbacks(self) -> list[tuple[Callable[[Self], Any], Context]]: ...
def add_done_callback(self, fn: Callable[[Self], object], /, *, context: Context | None = None) -> None: ... def add_done_callback(self, fn: Callable[[Self], object], /, *, context: Context | None = None) -> None: ...
if sys.version_info >= (3, 9): def cancel(self, msg: Any | None = None) -> bool: ...
def cancel(self, msg: Any | None = None) -> bool: ...
else:
def cancel(self) -> bool: ...
def cancelled(self) -> bool: ... def cancelled(self) -> bool: ...
def done(self) -> bool: ... def done(self) -> bool: ...
def result(self) -> _T: ... def result(self) -> _T: ...
@ -45,15 +38,12 @@ class Future(Awaitable[_T]):
def __await__(self) -> Generator[Any, None, _T]: ... def __await__(self) -> Generator[Any, None, _T]: ...
@property @property
def _loop(self) -> AbstractEventLoop: ... def _loop(self) -> AbstractEventLoop: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co] _TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co]
elif sys.version_info >= (3, 9):
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
else: else:
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Awaitable[_T_co] _TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
# mypy and pyright complain that a subclass of an invariant class shouldn't be covariant. # mypy and pyright complain that a subclass of an invariant class shouldn't be covariant.
# While this is true in general, here it's sort-of okay to have a covariant subclass, # While this is true in general, here it's sort-of okay to have a covariant subclass,
@ -99,13 +89,8 @@ class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportIn
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
def cancelling(self) -> int: ... def cancelling(self) -> int: ...
def uncancel(self) -> int: ... def uncancel(self) -> int: ...
if sys.version_info < (3, 9):
@classmethod def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def current_task(cls, loop: AbstractEventLoop | None = None) -> Task[Any] | None: ...
@classmethod
def all_tasks(cls, loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def get_event_loop() -> AbstractEventLoop: ... def get_event_loop() -> AbstractEventLoop: ...
def get_running_loop() -> AbstractEventLoop: ... def get_running_loop() -> AbstractEventLoop: ...

View File

@ -1,4 +1,3 @@
import sys
from _typeshed import ReadableBuffer from _typeshed import ReadableBuffer
from typing import ClassVar, final from typing import ClassVar, final
from typing_extensions import Self from typing_extensions import Self
@ -21,44 +20,24 @@ class blake2b:
block_size: int block_size: int
digest_size: int digest_size: int
name: str name: str
if sys.version_info >= (3, 9): def __new__(
def __new__( cls,
cls, data: ReadableBuffer = b"",
data: ReadableBuffer = b"", /,
/, *,
*, digest_size: int = 64,
digest_size: int = 64, key: ReadableBuffer = b"",
key: ReadableBuffer = b"", salt: ReadableBuffer = b"",
salt: ReadableBuffer = b"", person: ReadableBuffer = b"",
person: ReadableBuffer = b"", fanout: int = 1,
fanout: int = 1, depth: int = 1,
depth: int = 1, leaf_size: int = 0,
leaf_size: int = 0, node_offset: int = 0,
node_offset: int = 0, node_depth: int = 0,
node_depth: int = 0, inner_size: int = 0,
inner_size: int = 0, last_node: bool = False,
last_node: bool = False, usedforsecurity: bool = True,
usedforsecurity: bool = True, ) -> Self: ...
) -> Self: ...
else:
def __new__(
cls,
data: ReadableBuffer = b"",
/,
*,
digest_size: int = 64,
key: ReadableBuffer = b"",
salt: ReadableBuffer = b"",
person: ReadableBuffer = b"",
fanout: int = 1,
depth: int = 1,
leaf_size: int = 0,
node_offset: int = 0,
node_depth: int = 0,
inner_size: int = 0,
last_node: bool = False,
) -> Self: ...
def copy(self) -> Self: ... def copy(self) -> Self: ...
def digest(self) -> bytes: ... def digest(self) -> bytes: ...
def hexdigest(self) -> str: ... def hexdigest(self) -> str: ...
@ -73,44 +52,24 @@ class blake2s:
block_size: int block_size: int
digest_size: int digest_size: int
name: str name: str
if sys.version_info >= (3, 9): def __new__(
def __new__( cls,
cls, data: ReadableBuffer = b"",
data: ReadableBuffer = b"", /,
/, *,
*, digest_size: int = 32,
digest_size: int = 32, key: ReadableBuffer = b"",
key: ReadableBuffer = b"", salt: ReadableBuffer = b"",
salt: ReadableBuffer = b"", person: ReadableBuffer = b"",
person: ReadableBuffer = b"", fanout: int = 1,
fanout: int = 1, depth: int = 1,
depth: int = 1, leaf_size: int = 0,
leaf_size: int = 0, node_offset: int = 0,
node_offset: int = 0, node_depth: int = 0,
node_depth: int = 0, inner_size: int = 0,
inner_size: int = 0, last_node: bool = False,
last_node: bool = False, usedforsecurity: bool = True,
usedforsecurity: bool = True, ) -> Self: ...
) -> Self: ...
else:
def __new__(
cls,
data: ReadableBuffer = b"",
/,
*,
digest_size: int = 32,
key: ReadableBuffer = b"",
salt: ReadableBuffer = b"",
person: ReadableBuffer = b"",
fanout: int = 1,
depth: int = 1,
leaf_size: int = 0,
node_offset: int = 0,
node_depth: int = 0,
inner_size: int = 0,
last_node: bool = False,
) -> Self: ...
def copy(self) -> Self: ... def copy(self) -> Self: ...
def digest(self) -> bytes: ... def digest(self) -> bytes: ...
def hexdigest(self) -> str: ... def hexdigest(self) -> str: ...

View File

@ -81,26 +81,12 @@ def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> t
def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ... def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ...
def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def raw_unicode_escape_decode(
if sys.version_info >= (3, 9): data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
def raw_unicode_escape_decode( ) -> tuple[str, int]: ...
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
) -> tuple[str, int]: ...
else:
def raw_unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
def raw_unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def raw_unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def readbuffer_encode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ... def readbuffer_encode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ...
def unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /) -> tuple[str, int]: ...
if sys.version_info >= (3, 9):
def unicode_escape_decode(
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
) -> tuple[str, int]: ...
else:
def unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
def unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
def utf_16_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ... def utf_16_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
def utf_16_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def utf_16_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...

View File

@ -1,7 +1,7 @@
import sys import sys
from abc import abstractmethod from abc import abstractmethod
from types import MappingProxyType from types import MappingProxyType
from typing import ( # noqa: Y022,Y038 from typing import ( # noqa: Y022,Y038,UP035
AbstractSet as Set, AbstractSet as Set,
AsyncGenerator as AsyncGenerator, AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable, AsyncIterable as AsyncIterable,
@ -61,7 +61,7 @@ __all__ = [
"MutableSequence", "MutableSequence",
] ]
if sys.version_info < (3, 14): if sys.version_info < (3, 14):
from typing import ByteString as ByteString # noqa: Y057 from typing import ByteString as ByteString # noqa: Y057,UP035
__all__ += ["ByteString"] __all__ += ["ByteString"]

View File

@ -1,11 +1,8 @@
import sys
from collections.abc import Callable, Iterator, Mapping from collections.abc import Callable, Iterator, Mapping
from types import GenericAlias
from typing import Any, ClassVar, Generic, TypeVar, final, overload from typing import Any, ClassVar, Generic, TypeVar, final, overload
from typing_extensions import ParamSpec, Self from typing_extensions import ParamSpec, Self
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T") _T = TypeVar("_T")
_D = TypeVar("_D") _D = TypeVar("_D")
_P = ParamSpec("_P") _P = ParamSpec("_P")
@ -27,8 +24,7 @@ class ContextVar(Generic[_T]):
def get(self, default: _D, /) -> _D | _T: ... def get(self, default: _D, /) -> _D | _T: ...
def set(self, value: _T, /) -> Token[_T]: ... def set(self, value: _T, /) -> Token[_T]: ...
def reset(self, token: Token[_T], /) -> None: ... def reset(self, token: Token[_T], /) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
@final @final
class Token(Generic[_T]): class Token(Generic[_T]):
@ -38,8 +34,7 @@ class Token(Generic[_T]):
def old_value(self) -> Any: ... # returns either _T or MISSING, but that's hard to express def old_value(self) -> Any: ... # returns either _T or MISSING, but that's hard to express
MISSING: ClassVar[object] MISSING: ClassVar[object]
__hash__: ClassVar[None] # type: ignore[assignment] __hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def copy_context() -> Context: ... def copy_context() -> Context: ...

View File

@ -4,12 +4,10 @@ from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
from abc import abstractmethod from abc import abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p from ctypes import CDLL, ArgumentError as ArgumentError, c_void_p
from types import GenericAlias
from typing import Any, ClassVar, Generic, TypeVar, final, overload, type_check_only from typing import Any, ClassVar, Generic, TypeVar, final, overload, type_check_only
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T") _T = TypeVar("_T")
_CT = TypeVar("_CT", bound=_CData) _CT = TypeVar("_CT", bound=_CData)
@ -292,7 +290,7 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
@raw.setter @raw.setter
def raw(self, value: ReadableBuffer) -> None: ... def raw(self, value: ReadableBuffer) -> None: ...
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
# TODO These methods cannot be annotated correctly at the moment. # TODO: These methods cannot be annotated correctly at the moment.
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT # All of these "Any"s stand for the array's element type, but it's not possible to use _CT
# here, because of a special feature of ctypes. # here, because of a special feature of ctypes.
# By default, when accessing an element of an Array[_CT], the returned object has type _CT. # By default, when accessing an element of an Array[_CT], the returned object has type _CT.
@ -317,8 +315,7 @@ class Array(_CData, Generic[_CT], metaclass=_PyCArrayType):
# Can't inherit from Sized because the metaclass conflict between # Can't inherit from Sized because the metaclass conflict between
# Sized and _CData prevents using _CDataMeta. # Sized and _CData prevents using _CDataMeta.
def __len__(self) -> int: ... def __len__(self) -> int: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def addressof(obj: _CData | _CDataType, /) -> int: ... def addressof(obj: _CData | _CDataType, /) -> int: ...
def alignment(obj_or_type: _CData | _CDataType | type[_CData | _CDataType], /) -> int: ... def alignment(obj_or_type: _CData | _CDataType | type[_CData | _CDataType], /) -> int: ...

View File

@ -95,13 +95,14 @@ BUTTON4_DOUBLE_CLICKED: int
BUTTON4_PRESSED: int BUTTON4_PRESSED: int
BUTTON4_RELEASED: int BUTTON4_RELEASED: int
BUTTON4_TRIPLE_CLICKED: int BUTTON4_TRIPLE_CLICKED: int
# Darwin ncurses doesn't provide BUTTON5_* constants # Darwin ncurses doesn't provide BUTTON5_* constants prior to 3.12.10 and 3.13.3
if sys.version_info >= (3, 10) and sys.platform != "darwin": if sys.version_info >= (3, 10):
BUTTON5_PRESSED: int if sys.version_info >= (3, 12) or sys.platform != "darwin":
BUTTON5_RELEASED: int BUTTON5_PRESSED: int
BUTTON5_CLICKED: int BUTTON5_RELEASED: int
BUTTON5_DOUBLE_CLICKED: int BUTTON5_CLICKED: int
BUTTON5_TRIPLE_CLICKED: int BUTTON5_DOUBLE_CLICKED: int
BUTTON5_TRIPLE_CLICKED: int
BUTTON_ALT: int BUTTON_ALT: int
BUTTON_CTRL: int BUTTON_CTRL: int
BUTTON_SHIFT: int BUTTON_SHIFT: int
@ -292,11 +293,8 @@ def erasechar() -> bytes: ...
def filter() -> None: ... def filter() -> None: ...
def flash() -> None: ... def flash() -> None: ...
def flushinp() -> None: ... def flushinp() -> None: ...
def get_escdelay() -> int: ...
if sys.version_info >= (3, 9): def get_tabsize() -> int: ...
def get_escdelay() -> int: ...
def get_tabsize() -> int: ...
def getmouse() -> tuple[int, int, int, int, int]: ... def getmouse() -> tuple[int, int, int, int, int]: ...
def getsyx() -> tuple[int, int]: ... def getsyx() -> tuple[int, int]: ...
def getwin(file: SupportsRead[bytes], /) -> window: ... def getwin(file: SupportsRead[bytes], /) -> window: ...
@ -341,11 +339,8 @@ def resetty() -> None: ...
def resize_term(nlines: int, ncols: int, /) -> None: ... def resize_term(nlines: int, ncols: int, /) -> None: ...
def resizeterm(nlines: int, ncols: int, /) -> None: ... def resizeterm(nlines: int, ncols: int, /) -> None: ...
def savetty() -> None: ... def savetty() -> None: ...
def set_escdelay(ms: int, /) -> None: ...
if sys.version_info >= (3, 9): def set_tabsize(size: int, /) -> None: ...
def set_escdelay(ms: int, /) -> None: ...
def set_tabsize(size: int, /) -> None: ...
def setsyx(y: int, x: int, /) -> None: ... def setsyx(y: int, x: int, /) -> None: ...
def setupterm(term: str | None = None, fd: int = -1) -> None: ... def setupterm(term: str | None = None, fd: int = -1) -> None: ...
def start_color() -> None: ... def start_color() -> None: ...

View File

@ -1,33 +0,0 @@
from collections.abc import Callable
from types import TracebackType
from typing import Any, NoReturn, overload
from typing_extensions import TypeVarTuple, Unpack
__all__ = ["error", "start_new_thread", "exit", "get_ident", "allocate_lock", "interrupt_main", "LockType", "RLock"]
_Ts = TypeVarTuple("_Ts")
TIMEOUT_MAX: int
error = RuntimeError
@overload
def start_new_thread(function: Callable[[Unpack[_Ts]], object], args: tuple[Unpack[_Ts]]) -> None: ...
@overload
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any]) -> None: ...
def exit() -> NoReturn: ...
def get_ident() -> int: ...
def allocate_lock() -> LockType: ...
def stack_size(size: int | None = None) -> int: ...
class LockType:
locked_status: bool
def acquire(self, waitflag: bool | None = None, timeout: int = -1) -> bool: ...
def __enter__(self, waitflag: bool | None = None, timeout: int = -1) -> bool: ...
def __exit__(self, typ: type[BaseException] | None, val: BaseException | None, tb: TracebackType | None) -> None: ...
def release(self) -> bool: ...
def locked(self) -> bool: ...
class RLock(LockType):
def release(self) -> None: ... # type: ignore[override]
def interrupt_main() -> None: ...

View File

@ -1,56 +0,0 @@
from _threading_local import local as local
from _typeshed import ProfileFunction, TraceFunction
from threading import (
TIMEOUT_MAX as TIMEOUT_MAX,
Barrier as Barrier,
BoundedSemaphore as BoundedSemaphore,
BrokenBarrierError as BrokenBarrierError,
Condition as Condition,
Event as Event,
ExceptHookArgs as ExceptHookArgs,
Lock as Lock,
RLock as RLock,
Semaphore as Semaphore,
Thread as Thread,
ThreadError as ThreadError,
Timer as Timer,
_DummyThread as _DummyThread,
_RLock as _RLock,
excepthook as excepthook,
)
__all__ = [
"get_ident",
"active_count",
"Condition",
"current_thread",
"enumerate",
"main_thread",
"TIMEOUT_MAX",
"Event",
"Lock",
"RLock",
"Semaphore",
"BoundedSemaphore",
"Thread",
"Barrier",
"BrokenBarrierError",
"Timer",
"ThreadError",
"setprofile",
"settrace",
"local",
"stack_size",
"ExceptHookArgs",
"excepthook",
]
def active_count() -> int: ...
def current_thread() -> Thread: ...
def currentThread() -> Thread: ...
def get_ident() -> int: ...
def enumerate() -> list[Thread]: ...
def main_thread() -> Thread: ...
def settrace(func: TraceFunction) -> None: ...
def setprofile(func: ProfileFunction | None) -> None: ...
def stack_size(size: int | None = None) -> int: ...

View File

@ -37,53 +37,42 @@ class HASH:
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
class UnsupportedDigestmodError(ValueError): ... class UnsupportedDigestmodError(ValueError): ...
if sys.version_info >= (3, 9): class HASHXOF(HASH):
class HASHXOF(HASH): def digest(self, length: int) -> bytes: ... # type: ignore[override]
def digest(self, length: int) -> bytes: ... # type: ignore[override] def hexdigest(self, length: int) -> str: ... # type: ignore[override]
def hexdigest(self, length: int) -> str: ... # type: ignore[override]
@final @final
class HMAC: class HMAC:
@property @property
def digest_size(self) -> int: ... def digest_size(self) -> int: ...
@property @property
def block_size(self) -> int: ... def block_size(self) -> int: ...
@property @property
def name(self) -> str: ... def name(self) -> str: ...
def copy(self) -> Self: ... def copy(self) -> Self: ...
def digest(self) -> bytes: ... def digest(self) -> bytes: ...
def hexdigest(self) -> str: ... def hexdigest(self) -> str: ...
def update(self, msg: ReadableBuffer) -> None: ... def update(self, msg: ReadableBuffer) -> None: ...
@overload
def compare_digest(a: ReadableBuffer, b: ReadableBuffer, /) -> bool: ...
@overload
def compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...
def get_fips_mode() -> int: ...
def hmac_new(key: bytes | bytearray, msg: ReadableBuffer = b"", digestmod: _DigestMod = None) -> HMAC: ...
def new(name: str, string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_md5(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha1(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_shake_128(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
def openssl_shake_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
else:
def new(name: str, string: ReadableBuffer = b"") -> HASH: ...
def openssl_md5(string: ReadableBuffer = b"") -> HASH: ...
def openssl_sha1(string: ReadableBuffer = b"") -> HASH: ...
def openssl_sha224(string: ReadableBuffer = b"") -> HASH: ...
def openssl_sha256(string: ReadableBuffer = b"") -> HASH: ...
def openssl_sha384(string: ReadableBuffer = b"") -> HASH: ...
def openssl_sha512(string: ReadableBuffer = b"") -> HASH: ...
@overload
def compare_digest(a: ReadableBuffer, b: ReadableBuffer, /) -> bool: ...
@overload
def compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...
def get_fips_mode() -> int: ...
def hmac_new(key: bytes | bytearray, msg: ReadableBuffer = b"", digestmod: _DigestMod = None) -> HMAC: ...
def new(name: str, string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_md5(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha1(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_224(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_384(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_sha3_512(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ...
def openssl_shake_128(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
def openssl_shake_256(string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASHXOF: ...
def hmac_digest(key: bytes | bytearray, msg: ReadableBuffer, digest: str) -> bytes: ... def hmac_digest(key: bytes | bytearray, msg: ReadableBuffer, digest: str) -> bytes: ...
def pbkdf2_hmac( def pbkdf2_hmac(
hash_name: str, password: ReadableBuffer, salt: ReadableBuffer, iterations: int, dklen: int | None = None hash_name: str, password: ReadableBuffer, salt: ReadableBuffer, iterations: int, dklen: int | None = None

View File

@ -1,4 +1,3 @@
import sys
from _typeshed import ReadableBuffer, SupportsWrite from _typeshed import ReadableBuffer, SupportsWrite
from collections.abc import Callable, Iterable, Iterator, Mapping from collections.abc import Callable, Iterable, Iterator, Mapping
from pickle import PickleBuffer as PickleBuffer from pickle import PickleBuffer as PickleBuffer
@ -75,10 +74,9 @@ class Pickler:
def memo(self, value: PicklerMemoProxy | dict[int, tuple[int, Any]]) -> None: ... def memo(self, value: PicklerMemoProxy | dict[int, tuple[int, Any]]) -> None: ...
def dump(self, obj: Any, /) -> None: ... def dump(self, obj: Any, /) -> None: ...
def clear_memo(self) -> None: ... def clear_memo(self) -> None: ...
if sys.version_info >= (3, 13):
def persistent_id(self, obj: Any, /) -> Any: ... # this method has no default implementation for Python < 3.13
else: def persistent_id(self, obj: Any, /) -> Any: ...
persistent_id: Callable[[Any], Any]
@type_check_only @type_check_only
class UnpicklerMemoProxy: class UnpicklerMemoProxy:
@ -101,7 +99,6 @@ class Unpickler:
def memo(self, value: UnpicklerMemoProxy | dict[int, tuple[int, Any]]) -> None: ... def memo(self, value: UnpicklerMemoProxy | dict[int, tuple[int, Any]]) -> None: ...
def load(self) -> Any: ... def load(self) -> Any: ...
def find_class(self, module_name: str, global_name: str, /) -> Any: ... def find_class(self, module_name: str, global_name: str, /) -> Any: ...
if sys.version_info >= (3, 13):
def persistent_load(self, pid: Any, /) -> Any: ... # this method has no default implementation for Python < 3.13
else: def persistent_load(self, pid: Any, /) -> Any: ...
persistent_load: Callable[[Any], Any]

View File

@ -1,9 +1,6 @@
import sys from types import GenericAlias
from typing import Any, Generic, TypeVar from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T") _T = TypeVar("_T")
class Empty(Exception): ... class Empty(Exception): ...
@ -16,5 +13,4 @@ class SimpleQueue(Generic[_T]):
def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ... def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ...
def put_nowait(self, item: _T) -> None: ... def put_nowait(self, item: _T) -> None: ...
def qsize(self) -> int: ... def qsize(self) -> int: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

View File

@ -78,7 +78,7 @@ if sys.platform == "win32":
SO_EXCLUSIVEADDRUSE: int SO_EXCLUSIVEADDRUSE: int
if sys.platform != "win32": if sys.platform != "win32":
SO_REUSEPORT: int SO_REUSEPORT: int
if sys.platform != "darwin": if sys.platform != "darwin" or sys.version_info >= (3, 13):
SO_BINDTODEVICE: int SO_BINDTODEVICE: int
if sys.platform != "win32" and sys.platform != "darwin": if sys.platform != "win32" and sys.platform != "darwin":
@ -192,7 +192,7 @@ if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "lin
IPPROTO_BIP: int # Not FreeBSD either IPPROTO_BIP: int # Not FreeBSD either
IPPROTO_MOBILE: int # Not FreeBSD either IPPROTO_MOBILE: int # Not FreeBSD either
IPPROTO_VRRP: int # Not FreeBSD either IPPROTO_VRRP: int # Not FreeBSD either
if sys.version_info >= (3, 9) and sys.platform == "linux": if sys.platform == "linux":
# Availability: Linux >= 2.6.20, FreeBSD >= 10.1 # Availability: Linux >= 2.6.20, FreeBSD >= 10.1
IPPROTO_UDPLITE: int IPPROTO_UDPLITE: int
if sys.version_info >= (3, 10) and sys.platform == "linux": if sys.version_info >= (3, 10) and sys.platform == "linux":
@ -250,29 +250,26 @@ IPV6_RECVTCLASS: int
IPV6_TCLASS: int IPV6_TCLASS: int
IPV6_UNICAST_HOPS: int IPV6_UNICAST_HOPS: int
IPV6_V6ONLY: int IPV6_V6ONLY: int
if sys.version_info >= (3, 9) or sys.platform != "darwin": IPV6_DONTFRAG: int
IPV6_DONTFRAG: int IPV6_HOPLIMIT: int
IPV6_HOPLIMIT: int IPV6_HOPOPTS: int
IPV6_HOPOPTS: int IPV6_PKTINFO: int
IPV6_PKTINFO: int IPV6_RECVRTHDR: int
IPV6_RECVRTHDR: int IPV6_RTHDR: int
IPV6_RTHDR: int
if sys.platform != "win32": if sys.platform != "win32":
IPV6_RTHDR_TYPE_0: int IPV6_RTHDR_TYPE_0: int
if sys.version_info >= (3, 9) or sys.platform != "darwin": IPV6_DSTOPTS: int
IPV6_DSTOPTS: int IPV6_NEXTHOP: int
IPV6_NEXTHOP: int IPV6_PATHMTU: int
IPV6_PATHMTU: int IPV6_RECVDSTOPTS: int
IPV6_RECVDSTOPTS: int IPV6_RECVHOPLIMIT: int
IPV6_RECVHOPLIMIT: int IPV6_RECVHOPOPTS: int
IPV6_RECVHOPOPTS: int IPV6_RECVPATHMTU: int
IPV6_RECVPATHMTU: int IPV6_RECVPKTINFO: int
IPV6_RECVPKTINFO: int IPV6_RTHDRDSTOPTS: int
IPV6_RTHDRDSTOPTS: int
if sys.platform != "win32" and sys.platform != "linux": if sys.platform != "win32" and sys.platform != "linux":
if sys.version_info >= (3, 9) or sys.platform != "darwin": IPV6_USE_MIN_MTU: int
IPV6_USE_MIN_MTU: int
EAI_AGAIN: int EAI_AGAIN: int
EAI_BADFLAGS: int EAI_BADFLAGS: int
@ -414,16 +411,10 @@ if sys.platform == "linux":
if sys.platform == "linux": if sys.platform == "linux":
# Availability: Linux >= 3.6 # Availability: Linux >= 3.6
CAN_RAW_FD_FRAMES: int CAN_RAW_FD_FRAMES: int
if sys.platform == "linux" and sys.version_info >= (3, 9):
# Availability: Linux >= 4.1 # Availability: Linux >= 4.1
CAN_RAW_JOIN_FILTERS: int CAN_RAW_JOIN_FILTERS: int
if sys.platform == "linux":
# Availability: Linux >= 2.6.25 # Availability: Linux >= 2.6.25
CAN_ISOTP: int CAN_ISOTP: int
if sys.platform == "linux" and sys.version_info >= (3, 9):
# Availability: Linux >= 5.4 # Availability: Linux >= 5.4
CAN_J1939: int CAN_J1939: int
@ -566,18 +557,16 @@ if sys.platform == "linux":
SO_VM_SOCKETS_BUFFER_MIN_SIZE: int SO_VM_SOCKETS_BUFFER_MIN_SIZE: int
VM_SOCKETS_INVALID_VERSION: int # undocumented VM_SOCKETS_INVALID_VERSION: int # undocumented
if sys.platform != "win32" or sys.version_info >= (3, 9): # Documented as only available on BSD, macOS, but empirically sometimes
# Documented as only available on BSD, macOS, but empirically sometimes # available on Windows
# available on Windows if sys.platform != "linux":
if sys.platform != "linux": AF_LINK: int
AF_LINK: int
has_ipv6: bool has_ipv6: bool
if sys.platform != "darwin" and sys.platform != "linux": if sys.platform != "darwin" and sys.platform != "linux":
if sys.platform != "win32" or sys.version_info >= (3, 9): BDADDR_ANY: str
BDADDR_ANY: str BDADDR_LOCAL: str
BDADDR_LOCAL: str
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux": if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
HCI_FILTER: int # not in NetBSD or DragonFlyBSD HCI_FILTER: int # not in NetBSD or DragonFlyBSD
@ -649,8 +638,7 @@ if sys.platform == "darwin":
SYSPROTO_CONTROL: int SYSPROTO_CONTROL: int
if sys.platform != "darwin" and sys.platform != "linux": if sys.platform != "darwin" and sys.platform != "linux":
if sys.version_info >= (3, 9) or sys.platform != "win32": AF_BLUETOOTH: int
AF_BLUETOOTH: int
if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux": if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "linux":
# Linux and some BSD support is explicit in the docs # Linux and some BSD support is explicit in the docs
@ -659,10 +647,9 @@ if sys.platform != "win32" and sys.platform != "darwin" and sys.platform != "lin
BTPROTO_L2CAP: int BTPROTO_L2CAP: int
BTPROTO_SCO: int # not in FreeBSD BTPROTO_SCO: int # not in FreeBSD
if sys.platform != "darwin" and sys.platform != "linux": if sys.platform != "darwin" and sys.platform != "linux":
if sys.version_info >= (3, 9) or sys.platform != "win32": BTPROTO_RFCOMM: int
BTPROTO_RFCOMM: int
if sys.version_info >= (3, 9) and sys.platform == "linux": if sys.platform == "linux":
UDPLITE_RECV_CSCOV: int UDPLITE_RECV_CSCOV: int
UDPLITE_SEND_CSCOV: int UDPLITE_SEND_CSCOV: int

View File

@ -1,4 +1,3 @@
import sys
from collections.abc import Sequence from collections.abc import Sequence
from tracemalloc import _FrameTuple, _TraceTuple from tracemalloc import _FrameTuple, _TraceTuple
@ -9,9 +8,6 @@ def get_traceback_limit() -> int: ...
def get_traced_memory() -> tuple[int, int]: ... def get_traced_memory() -> tuple[int, int]: ...
def get_tracemalloc_memory() -> int: ... def get_tracemalloc_memory() -> int: ...
def is_tracing() -> bool: ... def is_tracing() -> bool: ...
def reset_peak() -> None: ...
if sys.version_info >= (3, 9):
def reset_peak() -> None: ...
def start(nframe: int = 1, /) -> None: ... def start(nframe: int = 1, /) -> None: ...
def stop() -> None: ... def stop() -> None: ...

View File

@ -22,7 +22,7 @@ from typing import (
final, final,
overload, overload,
) )
from typing_extensions import Buffer, LiteralString, TypeAlias from typing_extensions import Buffer, LiteralString, Self as _Self, TypeAlias
_KT = TypeVar("_KT") _KT = TypeVar("_KT")
_KT_co = TypeVar("_KT_co", covariant=True) _KT_co = TypeVar("_KT_co", covariant=True)
@ -328,9 +328,9 @@ class structseq(Generic[_T_co]):
# The second parameter will accept a dict of any kind without raising an exception, # The second parameter will accept a dict of any kind without raising an exception,
# but only has any meaning if you supply it a dict where the keys are strings. # but only has any meaning if you supply it a dict where the keys are strings.
# https://github.com/python/typeshed/pull/6560#discussion_r767149830 # https://github.com/python/typeshed/pull/6560#discussion_r767149830
def __new__(cls: type[Self], sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> Self: ... def __new__(cls, sequence: Iterable[_T_co], dict: dict[str, Any] = ...) -> _Self: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __replace__(self: Self, **kwargs: Any) -> Self: ... def __replace__(self, **kwargs: Any) -> _Self: ...
# Superset of typing.AnyStr that also includes LiteralString # Superset of typing.AnyStr that also includes LiteralString
AnyOrLiteralStr = TypeVar("AnyOrLiteralStr", str, bytes, LiteralString) # noqa: Y001 AnyOrLiteralStr = TypeVar("AnyOrLiteralStr", str, bytes, LiteralString) # noqa: Y001

View File

@ -1,11 +1,8 @@
import sys
from collections.abc import Iterable, Iterator, MutableSet from collections.abc import Iterable, Iterator, MutableSet
from types import GenericAlias
from typing import Any, ClassVar, TypeVar, overload from typing import Any, ClassVar, TypeVar, overload
from typing_extensions import Self from typing_extensions import Self
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ["WeakSet"] __all__ = ["WeakSet"]
_S = TypeVar("_S") _S = TypeVar("_S")
@ -48,5 +45,4 @@ class WeakSet(MutableSet[_T]):
def union(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... def union(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
def __or__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ... def __or__(self, other: Iterable[_S]) -> WeakSet[_S | _T]: ...
def isdisjoint(self, other: Iterable[_T]) -> bool: ... def isdisjoint(self, other: Iterable[_T]) -> bool: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

View File

@ -1,12 +1,8 @@
import sys
from types import TracebackType from types import TracebackType
from typing import IO, Any, Literal, NamedTuple, overload from typing import IO, Any, Literal, NamedTuple, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 9): __all__ = ["Error", "open"]
__all__ = ["Error", "open"]
else:
__all__ = ["Error", "open", "openfp"]
class Error(Exception): ... class Error(Exception): ...
@ -81,11 +77,3 @@ def open(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ...
def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ... def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
@overload @overload
def open(f: _File, mode: str | None = None) -> Any: ... def open(f: _File, mode: str | None = None) -> Any: ...
if sys.version_info < (3, 9):
@overload
def openfp(f: _File, mode: Literal["r", "rb"]) -> Aifc_read: ...
@overload
def openfp(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
@overload
def openfp(f: _File, mode: str | None = None) -> Any: ...

View File

@ -17,6 +17,7 @@ __all__ = [
"MetavarTypeHelpFormatter", "MetavarTypeHelpFormatter",
"Namespace", "Namespace",
"Action", "Action",
"BooleanOptionalAction",
"ONE_OR_MORE", "ONE_OR_MORE",
"OPTIONAL", "OPTIONAL",
"PARSER", "PARSER",
@ -25,9 +26,6 @@ __all__ = [
"ZERO_OR_MORE", "ZERO_OR_MORE",
] ]
if sys.version_info >= (3, 9):
__all__ += ["BooleanOptionalAction"]
_T = TypeVar("_T") _T = TypeVar("_T")
_ActionT = TypeVar("_ActionT", bound=Action) _ActionT = TypeVar("_ActionT", bound=Action)
_ArgumentParserT = TypeVar("_ArgumentParserT", bound=ArgumentParser) _ArgumentParserT = TypeVar("_ArgumentParserT", bound=ArgumentParser)
@ -132,40 +130,22 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
_subparsers: _ArgumentGroup | None _subparsers: _ArgumentGroup | None
# Note: the constructor arguments are also used in _SubParsersAction.add_parser. # Note: the constructor arguments are also used in _SubParsersAction.add_parser.
if sys.version_info >= (3, 9): def __init__(
def __init__( self,
self, prog: str | None = None,
prog: str | None = None, usage: str | None = None,
usage: str | None = None, description: str | None = None,
description: str | None = None, epilog: str | None = None,
epilog: str | None = None, parents: Sequence[ArgumentParser] = [],
parents: Sequence[ArgumentParser] = [], formatter_class: _FormatterClass = ...,
formatter_class: _FormatterClass = ..., prefix_chars: str = "-",
prefix_chars: str = "-", fromfile_prefix_chars: str | None = None,
fromfile_prefix_chars: str | None = None, argument_default: Any = None,
argument_default: Any = None, conflict_handler: str = "error",
conflict_handler: str = "error", add_help: bool = True,
add_help: bool = True, allow_abbrev: bool = True,
allow_abbrev: bool = True, exit_on_error: bool = True,
exit_on_error: bool = True, ) -> None: ...
) -> None: ...
else:
def __init__(
self,
prog: str | None = None,
usage: str | None = None,
description: str | None = None,
epilog: str | None = None,
parents: Sequence[ArgumentParser] = [],
formatter_class: _FormatterClass = ...,
prefix_chars: str = "-",
fromfile_prefix_chars: str | None = None,
argument_default: Any = None,
conflict_handler: str = "error",
add_help: bool = True,
allow_abbrev: bool = True,
) -> None: ...
@overload @overload
def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ... def parse_args(self, args: Sequence[str] | None = None, namespace: None = None) -> Namespace: ...
@overload @overload
@ -352,8 +332,7 @@ class Action(_AttributeHolder):
def __call__( def __call__(
self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = None self, parser: ArgumentParser, namespace: Namespace, values: str | Sequence[Any] | None, option_string: str | None = None
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 9): def format_usage(self) -> str: ...
def format_usage(self) -> str: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
class BooleanOptionalAction(Action): class BooleanOptionalAction(Action):
@ -418,7 +397,7 @@ if sys.version_info >= (3, 12):
metavar: str | tuple[str, ...] | None = sentinel, metavar: str | tuple[str, ...] | None = sentinel,
) -> None: ... ) -> None: ...
elif sys.version_info >= (3, 9): else:
class BooleanOptionalAction(Action): class BooleanOptionalAction(Action):
@overload @overload
def __init__( def __init__(
@ -713,7 +692,7 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
exit_on_error: bool = ..., exit_on_error: bool = ...,
**kwargs: Any, # Accepting any additional kwargs for custom parser classes **kwargs: Any, # Accepting any additional kwargs for custom parser classes
) -> _ArgumentParserT: ... ) -> _ArgumentParserT: ...
elif sys.version_info >= (3, 9): else:
def add_parser( def add_parser(
self, self,
name: str, name: str,
@ -736,28 +715,6 @@ class _SubParsersAction(Action, Generic[_ArgumentParserT]):
exit_on_error: bool = ..., exit_on_error: bool = ...,
**kwargs: Any, # Accepting any additional kwargs for custom parser classes **kwargs: Any, # Accepting any additional kwargs for custom parser classes
) -> _ArgumentParserT: ... ) -> _ArgumentParserT: ...
else:
def add_parser(
self,
name: str,
*,
help: str | None = ...,
aliases: Sequence[str] = ...,
# Kwargs from ArgumentParser constructor
prog: str | None = ...,
usage: str | None = ...,
description: str | None = ...,
epilog: str | None = ...,
parents: Sequence[_ArgumentParserT] = ...,
formatter_class: _FormatterClass = ...,
prefix_chars: str = ...,
fromfile_prefix_chars: str | None = ...,
argument_default: Any = ...,
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]: ... def _get_subactions(self) -> list[Action]: ...

View File

@ -1,14 +1,10 @@
import sys import sys
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from collections.abc import Iterable from collections.abc import Iterable, MutableSequence
from types import GenericAlias
# pytype crashes if array inherits from collections.abc.MutableSequence instead of typing.MutableSequence from typing import Any, ClassVar, Literal, SupportsIndex, TypeVar, overload
from typing import Any, ClassVar, Literal, MutableSequence, SupportsIndex, TypeVar, overload # noqa: Y022
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 12):
from types import GenericAlias
_IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"] _IntTypeCode: TypeAlias = Literal["b", "B", "h", "H", "i", "I", "l", "L", "q", "Q"]
_FloatTypeCode: TypeAlias = Literal["f", "d"] _FloatTypeCode: TypeAlias = Literal["f", "d"]
_UnicodeTypeCode: TypeAlias = Literal["u"] _UnicodeTypeCode: TypeAlias = Literal["u"]
@ -60,9 +56,6 @@ class array(MutableSequence[_T]):
def tofile(self, f: SupportsWrite[bytes], /) -> None: ... def tofile(self, f: SupportsWrite[bytes], /) -> None: ...
def tolist(self) -> list[_T]: ... def tolist(self) -> list[_T]: ...
def tounicode(self) -> str: ... def tounicode(self) -> str: ...
if sys.version_info < (3, 9):
def fromstring(self, buffer: str | ReadableBuffer, /) -> None: ...
def tostring(self) -> bytes: ...
__hash__: ClassVar[None] # type: ignore[assignment] __hash__: ClassVar[None] # type: ignore[assignment]
def __len__(self) -> int: ... def __len__(self) -> int: ...

View File

@ -1144,8 +1144,7 @@ class Tuple(expr):
__match_args__ = ("elts", "ctx") __match_args__ = ("elts", "ctx")
elts: list[expr] elts: list[expr]
ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__` ctx: expr_context # Not present in Python < 3.13 if not passed to `__init__`
if sys.version_info >= (3, 9): dims: list[expr]
dims: list[expr]
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__(self, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ... def __init__(self, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> None: ...
else: else:
@ -1155,16 +1154,10 @@ class Tuple(expr):
def __replace__(self, *, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ... def __replace__(self, *, elts: list[expr] = ..., ctx: expr_context = ..., **kwargs: Unpack[_Attributes]) -> Self: ...
@deprecated("Deprecated since Python 3.9.") @deprecated("Deprecated since Python 3.9.")
class slice(AST): ... # deprecated and moved to ast.py for >= (3, 9) class slice(AST): ...
if sys.version_info >= (3, 9): _Slice: typing_extensions.TypeAlias = expr
_Slice: typing_extensions.TypeAlias = expr _SliceAttributes: typing_extensions.TypeAlias = _Attributes
_SliceAttributes: typing_extensions.TypeAlias = _Attributes
else:
# alias for use with variables named slice
_Slice: typing_extensions.TypeAlias = slice
class _SliceAttributes(TypedDict): ...
class Slice(_Slice): class Slice(_Slice):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
@ -1187,37 +1180,26 @@ class Slice(_Slice):
) -> Self: ... ) -> Self: ...
@deprecated("Deprecated since Python 3.9. Use ast.Tuple instead.") @deprecated("Deprecated since Python 3.9. Use ast.Tuple instead.")
class ExtSlice(slice): # deprecated and moved to ast.py if sys.version_info >= (3, 9) class ExtSlice(slice):
if sys.version_info >= (3, 9): def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_SliceAttributes]) -> Tuple: ... # type: ignore[misc]
def __new__(cls, dims: Iterable[slice] = (), **kwargs: Unpack[_SliceAttributes]) -> Tuple: ... # type: ignore[misc]
else:
dims: list[slice]
def __init__(self, dims: list[slice], **kwargs: Unpack[_SliceAttributes]) -> None: ...
@deprecated("Deprecated since Python 3.9. Use the index value directly instead.") @deprecated("Deprecated since Python 3.9. Use the index value directly instead.")
class Index(slice): # deprecated and moved to ast.py if sys.version_info >= (3, 9) class Index(slice):
if sys.version_info >= (3, 9): def __new__(cls, value: expr, **kwargs: Unpack[_SliceAttributes]) -> expr: ... # type: ignore[misc]
def __new__(cls, value: expr, **kwargs: Unpack[_SliceAttributes]) -> expr: ... # type: ignore[misc]
else:
value: expr
def __init__(self, value: expr, **kwargs: Unpack[_SliceAttributes]) -> None: ...
class expr_context(AST): ... class expr_context(AST): ...
@deprecated("Deprecated since Python 3.9. Unused in Python 3.") @deprecated("Deprecated since Python 3.9. Unused in Python 3.")
class AugLoad(expr_context): ... # deprecated and moved to ast.py if sys.version_info >= (3, 9) class AugLoad(expr_context): ...
@deprecated("Deprecated since Python 3.9. Unused in Python 3.") @deprecated("Deprecated since Python 3.9. Unused in Python 3.")
class AugStore(expr_context): ... # deprecated and moved to ast.py if sys.version_info >= (3, 9) class AugStore(expr_context): ...
@deprecated("Deprecated since Python 3.9. Unused in Python 3.") @deprecated("Deprecated since Python 3.9. Unused in Python 3.")
class Param(expr_context): ... # deprecated and moved to ast.py if sys.version_info >= (3, 9) class Param(expr_context): ...
@deprecated("Deprecated since Python 3.9. Unused in Python 3.") @deprecated("Deprecated since Python 3.9. Unused in Python 3.")
class Suite(mod): # deprecated and moved to ast.py if sys.version_info >= (3, 9) class Suite(mod): ...
if sys.version_info < (3, 9):
body: list[stmt]
def __init__(self, body: list[stmt]) -> None: ...
class Load(expr_context): ... class Load(expr_context): ...
class Store(expr_context): ... class Store(expr_context): ...
@ -1702,8 +1684,7 @@ if sys.version_info >= (3, 12):
) -> Self: ... ) -> Self: ...
class _ABC(type): class _ABC(type):
if sys.version_info >= (3, 9): def __init__(cls, *args: Unused) -> None: ...
def __init__(cls, *args: Unused) -> None: ...
if sys.version_info < (3, 14): if sys.version_info < (3, 14):
@deprecated("Replaced by ast.Constant; removed in Python 3.14") @deprecated("Replaced by ast.Constant; removed in Python 3.14")
@ -1894,14 +1875,11 @@ if sys.version_info >= (3, 13):
show_empty: bool = False, show_empty: bool = False,
) -> str: ... ) -> str: ...
elif sys.version_info >= (3, 9): else:
def dump( def dump(
node: AST, annotate_fields: bool = True, include_attributes: bool = False, *, indent: int | str | None = None node: AST, annotate_fields: bool = True, include_attributes: bool = False, *, indent: int | str | None = None
) -> str: ... ) -> str: ...
else:
def dump(node: AST, annotate_fields: bool = True, include_attributes: bool = False) -> str: ...
def copy_location(new_node: _T, old_node: AST) -> _T: ... def copy_location(new_node: _T, old_node: AST) -> _T: ...
def fix_missing_locations(node: _T) -> _T: ... def fix_missing_locations(node: _T) -> _T: ...
def increment_lineno(node: _T, n: int = 1) -> _T: ... def increment_lineno(node: _T, n: int = 1) -> _T: ...
@ -2059,8 +2037,5 @@ class NodeTransformer(NodeVisitor):
# The usual return type is AST | None, but Iterable[AST] # The usual return type is AST | None, but Iterable[AST]
# is also allowed in some cases -- this needs to be mapped. # is also allowed in some cases -- this needs to be mapped.
if sys.version_info >= (3, 9): def unparse(ast_obj: AST) -> str: ...
def unparse(ast_obj: AST) -> str: ... def main() -> None: ...
if sys.version_info >= (3, 9):
def main() -> None: ...

View File

@ -18,11 +18,9 @@ from .runners import *
from .streams import * from .streams import *
from .subprocess import * from .subprocess import *
from .tasks import * from .tasks import *
from .threads import *
from .transports import * from .transports import *
if sys.version_info >= (3, 9):
from .threads import *
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from .taskgroups import * from .taskgroups import *
from .timeouts import * from .timeouts import *
@ -412,7 +410,7 @@ if sys.platform == "win32":
"WindowsSelectorEventLoopPolicy", # from windows_events "WindowsSelectorEventLoopPolicy", # from windows_events
"WindowsProactorEventLoopPolicy", # from windows_events "WindowsProactorEventLoopPolicy", # from windows_events
) )
elif sys.version_info >= (3, 9): else:
__all__ = ( __all__ = (
"BaseEventLoop", # from base_events "BaseEventLoop", # from base_events
"Server", # from base_events "Server", # from base_events
@ -499,91 +497,6 @@ if sys.platform == "win32":
"WindowsSelectorEventLoopPolicy", # from windows_events "WindowsSelectorEventLoopPolicy", # from windows_events
"WindowsProactorEventLoopPolicy", # from windows_events "WindowsProactorEventLoopPolicy", # from windows_events
) )
else:
__all__ = (
"BaseEventLoop", # from base_events
"coroutine", # from coroutines
"iscoroutinefunction", # from coroutines
"iscoroutine", # from coroutines
"AbstractEventLoopPolicy", # from events
"AbstractEventLoop", # from events
"AbstractServer", # from events
"Handle", # from events
"TimerHandle", # from events
"get_event_loop_policy", # from events
"set_event_loop_policy", # from events
"get_event_loop", # from events
"set_event_loop", # from events
"new_event_loop", # from events
"get_child_watcher", # from events
"set_child_watcher", # from events
"_set_running_loop", # from events
"get_running_loop", # from events
"_get_running_loop", # from events
"CancelledError", # from exceptions
"InvalidStateError", # from exceptions
"TimeoutError", # from exceptions
"IncompleteReadError", # from exceptions
"LimitOverrunError", # from exceptions
"SendfileNotAvailableError", # from exceptions
"Future", # from futures
"wrap_future", # from futures
"isfuture", # from futures
"Lock", # from locks
"Event", # from locks
"Condition", # from locks
"Semaphore", # from locks
"BoundedSemaphore", # from locks
"BaseProtocol", # from protocols
"Protocol", # from protocols
"DatagramProtocol", # from protocols
"SubprocessProtocol", # from protocols
"BufferedProtocol", # from protocols
"run", # from runners
"Queue", # from queues
"PriorityQueue", # from queues
"LifoQueue", # from queues
"QueueFull", # from queues
"QueueEmpty", # from queues
"StreamReader", # from streams
"StreamWriter", # from streams
"StreamReaderProtocol", # from streams
"open_connection", # from streams
"start_server", # from streams
"create_subprocess_exec", # from subprocess
"create_subprocess_shell", # from subprocess
"Task", # from tasks
"create_task", # from tasks
"FIRST_COMPLETED", # from tasks
"FIRST_EXCEPTION", # from tasks
"ALL_COMPLETED", # from tasks
"wait", # from tasks
"wait_for", # from tasks
"as_completed", # from tasks
"sleep", # from tasks
"gather", # from tasks
"shield", # from tasks
"ensure_future", # from tasks
"run_coroutine_threadsafe", # from tasks
"current_task", # from tasks
"all_tasks", # from tasks
"_register_task", # from tasks
"_unregister_task", # from tasks
"_enter_task", # from tasks
"_leave_task", # from tasks
"BaseTransport", # from transports
"ReadTransport", # from transports
"WriteTransport", # from transports
"Transport", # from transports
"DatagramTransport", # from transports
"SubprocessTransport", # from transports
"SelectorEventLoop", # from windows_events
"ProactorEventLoop", # from windows_events
"IocpProactor", # from windows_events
"DefaultEventLoopPolicy", # from windows_events
"WindowsSelectorEventLoopPolicy", # from windows_events
"WindowsProactorEventLoopPolicy", # from windows_events
)
else: else:
if sys.version_info >= (3, 14): if sys.version_info >= (3, 14):
__all__ = ( __all__ = (
@ -974,7 +887,7 @@ else:
"ThreadedChildWatcher", # from unix_events "ThreadedChildWatcher", # from unix_events
"DefaultEventLoopPolicy", # from unix_events "DefaultEventLoopPolicy", # from unix_events
) )
elif sys.version_info >= (3, 9): else:
__all__ = ( __all__ = (
"BaseEventLoop", # from base_events "BaseEventLoop", # from base_events
"Server", # from base_events "Server", # from base_events
@ -1065,94 +978,6 @@ else:
"ThreadedChildWatcher", # from unix_events "ThreadedChildWatcher", # from unix_events
"DefaultEventLoopPolicy", # from unix_events "DefaultEventLoopPolicy", # from unix_events
) )
else:
__all__ = (
"BaseEventLoop", # from base_events
"coroutine", # from coroutines
"iscoroutinefunction", # from coroutines
"iscoroutine", # from coroutines
"AbstractEventLoopPolicy", # from events
"AbstractEventLoop", # from events
"AbstractServer", # from events
"Handle", # from events
"TimerHandle", # from events
"get_event_loop_policy", # from events
"set_event_loop_policy", # from events
"get_event_loop", # from events
"set_event_loop", # from events
"new_event_loop", # from events
"get_child_watcher", # from events
"set_child_watcher", # from events
"_set_running_loop", # from events
"get_running_loop", # from events
"_get_running_loop", # from events
"CancelledError", # from exceptions
"InvalidStateError", # from exceptions
"TimeoutError", # from exceptions
"IncompleteReadError", # from exceptions
"LimitOverrunError", # from exceptions
"SendfileNotAvailableError", # from exceptions
"Future", # from futures
"wrap_future", # from futures
"isfuture", # from futures
"Lock", # from locks
"Event", # from locks
"Condition", # from locks
"Semaphore", # from locks
"BoundedSemaphore", # from locks
"BaseProtocol", # from protocols
"Protocol", # from protocols
"DatagramProtocol", # from protocols
"SubprocessProtocol", # from protocols
"BufferedProtocol", # from protocols
"run", # from runners
"Queue", # from queues
"PriorityQueue", # from queues
"LifoQueue", # from queues
"QueueFull", # from queues
"QueueEmpty", # from queues
"StreamReader", # from streams
"StreamWriter", # from streams
"StreamReaderProtocol", # from streams
"open_connection", # from streams
"start_server", # from streams
"open_unix_connection", # from streams
"start_unix_server", # from streams
"create_subprocess_exec", # from subprocess
"create_subprocess_shell", # from subprocess
"Task", # from tasks
"create_task", # from tasks
"FIRST_COMPLETED", # from tasks
"FIRST_EXCEPTION", # from tasks
"ALL_COMPLETED", # from tasks
"wait", # from tasks
"wait_for", # from tasks
"as_completed", # from tasks
"sleep", # from tasks
"gather", # from tasks
"shield", # from tasks
"ensure_future", # from tasks
"run_coroutine_threadsafe", # from tasks
"current_task", # from tasks
"all_tasks", # from tasks
"_register_task", # from tasks
"_unregister_task", # from tasks
"_enter_task", # from tasks
"_leave_task", # from tasks
"BaseTransport", # from transports
"ReadTransport", # from transports
"WriteTransport", # from transports
"Transport", # from transports
"DatagramTransport", # from transports
"SubprocessTransport", # from transports
"SelectorEventLoop", # from unix_events
"AbstractChildWatcher", # from unix_events
"SafeChildWatcher", # from unix_events
"FastChildWatcher", # from unix_events
"MultiLoopChildWatcher", # from unix_events
"ThreadedChildWatcher", # from unix_events
"DefaultEventLoopPolicy", # from unix_events
)
_T_co = TypeVar("_T_co", covariant=True) _T_co = TypeVar("_T_co", covariant=True)

View File

@ -15,10 +15,7 @@ from typing import IO, Any, Literal, TypeVar, overload
from typing_extensions import TypeAlias, TypeVarTuple, Unpack from typing_extensions import TypeAlias, TypeVarTuple, Unpack
# Keep asyncio.__all__ updated with any changes to __all__ here # Keep asyncio.__all__ updated with any changes to __all__ here
if sys.version_info >= (3, 9): __all__ = ("BaseEventLoop", "Server")
__all__ = ("BaseEventLoop", "Server")
else:
__all__ = ("BaseEventLoop",)
_T = TypeVar("_T") _T = TypeVar("_T")
_Ts = TypeVarTuple("_Ts") _Ts = TypeVarTuple("_Ts")
@ -485,7 +482,7 @@ class BaseEventLoop(AbstractEventLoop):
def set_debug(self, enabled: bool) -> None: ... def set_debug(self, enabled: bool) -> None: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
async def shutdown_default_executor(self, timeout: float | None = None) -> None: ... async def shutdown_default_executor(self, timeout: float | None = None) -> None: ...
elif sys.version_info >= (3, 9): else:
async def shutdown_default_executor(self) -> None: ... async def shutdown_default_executor(self) -> None: ...
def __del__(self) -> None: ... def __del__(self) -> None: ...

View File

@ -138,27 +138,19 @@ class AbstractEventLoop:
@abstractmethod @abstractmethod
async def shutdown_asyncgens(self) -> None: ... async def shutdown_asyncgens(self) -> None: ...
# Methods scheduling callbacks. All these return Handles. # Methods scheduling callbacks. All these return Handles.
if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2 # "context" added in 3.9.10/3.10.2 for call_*
@abstractmethod @abstractmethod
def call_soon( def call_soon(
self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> Handle: ... ) -> Handle: ...
@abstractmethod @abstractmethod
def call_later( def call_later(
self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> TimerHandle: ... ) -> TimerHandle: ...
@abstractmethod @abstractmethod
def call_at( def call_at(
self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> TimerHandle: ... ) -> TimerHandle: ...
else:
@abstractmethod
def call_soon(self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> Handle: ...
@abstractmethod
def call_later(self, delay: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> TimerHandle: ...
@abstractmethod
def call_at(self, when: float, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> TimerHandle: ...
@abstractmethod @abstractmethod
def time(self) -> float: ... def time(self) -> float: ...
# Future methods # Future methods
@ -179,15 +171,11 @@ class AbstractEventLoop:
@abstractmethod @abstractmethod
def get_task_factory(self) -> _TaskFactory | None: ... def get_task_factory(self) -> _TaskFactory | None: ...
# Methods for interacting with threads # Methods for interacting with threads
if sys.version_info >= (3, 9): # "context" added in 3.9.10/3.10.2 # "context" added in 3.9.10/3.10.2
@abstractmethod @abstractmethod
def call_soon_threadsafe( def call_soon_threadsafe(
self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts], context: Context | None = None
) -> Handle: ... ) -> Handle: ...
else:
@abstractmethod
def call_soon_threadsafe(self, callback: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> Handle: ...
@abstractmethod @abstractmethod
def run_in_executor(self, executor: Executor | None, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ... def run_in_executor(self, executor: Executor | None, func: Callable[[Unpack[_Ts]], _T], *args: Unpack[_Ts]) -> Future[_T]: ...
@abstractmethod @abstractmethod
@ -607,9 +595,8 @@ class AbstractEventLoop:
def get_debug(self) -> bool: ... def get_debug(self) -> bool: ...
@abstractmethod @abstractmethod
def set_debug(self, enabled: bool) -> None: ... def set_debug(self, enabled: bool) -> None: ...
if sys.version_info >= (3, 9): @abstractmethod
@abstractmethod async def shutdown_default_executor(self) -> None: ...
async def shutdown_default_executor(self) -> None: ...
class AbstractEventLoopPolicy: class AbstractEventLoopPolicy:
@abstractmethod @abstractmethod

View File

@ -2,7 +2,7 @@ import enum
import sys import sys
from _typeshed import Unused from _typeshed import Unused
from collections import deque from collections import deque
from collections.abc import Callable, Generator from collections.abc import Callable
from types import TracebackType from types import TracebackType
from typing import Any, Literal, TypeVar from typing import Any, Literal, TypeVar
from typing_extensions import Self from typing_extensions import Self
@ -23,29 +23,11 @@ else:
_T = TypeVar("_T") _T = TypeVar("_T")
if sys.version_info >= (3, 9): class _ContextManagerMixin:
class _ContextManagerMixin: async def __aenter__(self) -> None: ...
async def __aenter__(self) -> None: ... async def __aexit__(
async def __aexit__( self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None ) -> None: ...
) -> None: ...
else:
class _ContextManager:
def __init__(self, lock: Lock | Semaphore) -> None: ...
def __enter__(self) -> None: ...
def __exit__(self, *args: Unused) -> None: ...
class _ContextManagerMixin:
# Apparently this exists to *prohibit* use as a context manager.
# def __enter__(self) -> NoReturn: ... see: https://github.com/python/typing/issues/1043
# def __exit__(self, *args: Any) -> None: ...
def __iter__(self) -> Generator[Any, None, _ContextManager]: ...
def __await__(self) -> Generator[Any, None, _ContextManager]: ...
async def __aenter__(self) -> None: ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> None: ...
class Lock(_ContextManagerMixin, _LoopBoundMixin): class Lock(_ContextManagerMixin, _LoopBoundMixin):
_waiters: deque[Future[Any]] | None _waiters: deque[Future[Any]] | None

View File

@ -1,10 +1,8 @@
import sys import sys
from asyncio.events import AbstractEventLoop from asyncio.events import AbstractEventLoop
from types import GenericAlias
from typing import Any, Generic, TypeVar from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
from .mixins import _LoopBoundMixin from .mixins import _LoopBoundMixin
else: else:
@ -48,8 +46,7 @@ class Queue(Generic[_T], _LoopBoundMixin): # noqa: Y059
def get_nowait(self) -> _T: ... def get_nowait(self) -> _T: ...
async def join(self) -> None: ... async def join(self) -> None: ...
def task_done(self) -> None: ... def task_done(self) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, type: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, type: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def shutdown(self, immediate: bool = False) -> None: ... def shutdown(self, immediate: bool = False) -> None: ...

View File

@ -407,10 +407,8 @@ else:
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co] _TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, _T_co]
elif sys.version_info >= (3, 9):
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
else: else:
_TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Awaitable[_T_co] _TaskCompatibleCoro: TypeAlias = Generator[_TaskYieldType, None, _T_co] | Coroutine[Any, Any, _T_co]
def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ... def all_tasks(loop: AbstractEventLoop | None = None) -> set[Task[Any]]: ...

View File

@ -30,7 +30,7 @@ if sys.platform != "win32":
"DefaultEventLoopPolicy", "DefaultEventLoopPolicy",
"EventLoop", "EventLoop",
) )
elif sys.version_info >= (3, 9): else:
# adds PidfdChildWatcher # adds PidfdChildWatcher
__all__ = ( __all__ = (
"SelectorEventLoop", "SelectorEventLoop",
@ -42,16 +42,6 @@ if sys.platform != "win32":
"ThreadedChildWatcher", "ThreadedChildWatcher",
"DefaultEventLoopPolicy", "DefaultEventLoopPolicy",
) )
else:
__all__ = (
"SelectorEventLoop",
"AbstractChildWatcher",
"SafeChildWatcher",
"FastChildWatcher",
"MultiLoopChildWatcher",
"ThreadedChildWatcher",
"DefaultEventLoopPolicy",
)
# This is also technically not available on Win, # This is also technically not available on Win,
# but other parts of typeshed need this definition. # but other parts of typeshed need this definition.
@ -239,16 +229,15 @@ if sys.platform != "win32":
def remove_child_handler(self, pid: int) -> bool: ... def remove_child_handler(self, pid: int) -> bool: ...
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
if sys.version_info >= (3, 9): class PidfdChildWatcher(AbstractChildWatcher):
class PidfdChildWatcher(AbstractChildWatcher): def __enter__(self) -> Self: ...
def __enter__(self) -> Self: ... def __exit__(
def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: types.TracebackType | None ) -> None: ...
) -> None: ... def is_active(self) -> bool: ...
def is_active(self) -> bool: ... def close(self) -> None: ...
def close(self) -> None: ... def attach_loop(self, loop: AbstractEventLoop | None) -> None: ...
def attach_loop(self, loop: AbstractEventLoop | None) -> None: ... def add_child_handler(
def add_child_handler( self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts]
self, pid: int, callback: Callable[[int, int, Unpack[_Ts]], object], *args: Unpack[_Ts] ) -> None: ...
) -> None: ... def remove_child_handler(self, pid: int) -> bool: ...
def remove_child_handler(self, pid: int) -> bool: ...

View File

@ -56,10 +56,6 @@ def encode(input: IO[bytes], output: IO[bytes]) -> None: ...
def encodebytes(s: ReadableBuffer) -> bytes: ... def encodebytes(s: ReadableBuffer) -> bytes: ...
def decodebytes(s: ReadableBuffer) -> bytes: ... def decodebytes(s: ReadableBuffer) -> bytes: ...
if sys.version_info < (3, 9):
def encodestring(s: ReadableBuffer) -> bytes: ...
def decodestring(s: ReadableBuffer) -> bytes: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def z85encode(s: ReadableBuffer) -> bytes: ... def z85encode(s: ReadableBuffer) -> bytes: ...
def z85decode(s: str | ReadableBuffer) -> bytes: ... def z85decode(s: str | ReadableBuffer) -> bytes: ...

View File

@ -32,11 +32,11 @@ from _typeshed import (
) )
from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from types import CellType, CodeType, TracebackType from types import CellType, CodeType, GenericAlias, TracebackType
# mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping} # mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping}
# are imported from collections.abc in builtins.pyi # are imported from collections.abc in builtins.pyi
from typing import ( # noqa: Y022 from typing import ( # noqa: Y022,UP035
IO, IO,
Any, Any,
BinaryIO, BinaryIO,
@ -72,9 +72,6 @@ from typing_extensions import ( # noqa: Y023
deprecated, deprecated,
) )
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T") _T = TypeVar("_T")
_I = TypeVar("_I", default=int) _I = TypeVar("_I", default=int)
_T_co = TypeVar("_T_co", covariant=True) _T_co = TypeVar("_T_co", covariant=True)
@ -377,10 +374,8 @@ class float:
def __rpow__(self, value: float, mod: None = None, /) -> Any: ... def __rpow__(self, value: float, mod: None = None, /) -> Any: ...
def __getnewargs__(self) -> tuple[float]: ... def __getnewargs__(self) -> tuple[float]: ...
def __trunc__(self) -> int: ... def __trunc__(self) -> int: ...
if sys.version_info >= (3, 9): def __ceil__(self) -> int: ...
def __ceil__(self) -> int: ... def __floor__(self) -> int: ...
def __floor__(self) -> int: ...
@overload @overload
def __round__(self, ndigits: None = None, /) -> int: ... def __round__(self, ndigits: None = None, /) -> int: ...
@overload @overload
@ -519,16 +514,15 @@ class str(Sequence[str]):
) -> LiteralString: ... ) -> LiteralString: ...
@overload @overload
def replace(self, old: str, new: str, count: SupportsIndex = -1, /) -> str: ... # type: ignore[misc] def replace(self, old: str, new: str, count: SupportsIndex = -1, /) -> str: ... # type: ignore[misc]
if sys.version_info >= (3, 9):
@overload
def removeprefix(self: LiteralString, prefix: LiteralString, /) -> LiteralString: ...
@overload
def removeprefix(self, prefix: str, /) -> str: ... # type: ignore[misc]
@overload
def removesuffix(self: LiteralString, suffix: LiteralString, /) -> LiteralString: ...
@overload
def removesuffix(self, suffix: str, /) -> str: ... # type: ignore[misc]
@overload
def removeprefix(self: LiteralString, prefix: LiteralString, /) -> LiteralString: ...
@overload
def removeprefix(self, prefix: str, /) -> str: ... # type: ignore[misc]
@overload
def removesuffix(self: LiteralString, suffix: LiteralString, /) -> LiteralString: ...
@overload
def removesuffix(self, suffix: str, /) -> str: ... # type: ignore[misc]
def rfind(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ... def rfind(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
def rindex(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ... def rindex(self, sub: str, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /) -> int: ...
@overload @overload
@ -666,10 +660,8 @@ class bytes(Sequence[int]):
def lstrip(self, bytes: ReadableBuffer | None = None, /) -> bytes: ... def lstrip(self, bytes: ReadableBuffer | None = None, /) -> bytes: ...
def partition(self, sep: ReadableBuffer, /) -> tuple[bytes, bytes, bytes]: ... def partition(self, sep: ReadableBuffer, /) -> tuple[bytes, bytes, bytes]: ...
def replace(self, old: ReadableBuffer, new: ReadableBuffer, count: SupportsIndex = -1, /) -> bytes: ... def replace(self, old: ReadableBuffer, new: ReadableBuffer, count: SupportsIndex = -1, /) -> bytes: ...
if sys.version_info >= (3, 9): def removeprefix(self, prefix: ReadableBuffer, /) -> bytes: ...
def removeprefix(self, prefix: ReadableBuffer, /) -> bytes: ... def removesuffix(self, suffix: ReadableBuffer, /) -> bytes: ...
def removesuffix(self, suffix: ReadableBuffer, /) -> bytes: ...
def rfind( def rfind(
self, sub: ReadableBuffer | SupportsIndex, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., / self, sub: ReadableBuffer | SupportsIndex, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /
) -> int: ... ) -> int: ...
@ -771,10 +763,8 @@ class bytearray(MutableSequence[int]):
def partition(self, sep: ReadableBuffer, /) -> tuple[bytearray, bytearray, bytearray]: ... def partition(self, sep: ReadableBuffer, /) -> tuple[bytearray, bytearray, bytearray]: ...
def pop(self, index: int = -1, /) -> int: ... def pop(self, index: int = -1, /) -> int: ...
def remove(self, value: int, /) -> None: ... def remove(self, value: int, /) -> None: ...
if sys.version_info >= (3, 9): def removeprefix(self, prefix: ReadableBuffer, /) -> bytearray: ...
def removeprefix(self, prefix: ReadableBuffer, /) -> bytearray: ... def removesuffix(self, suffix: ReadableBuffer, /) -> bytearray: ...
def removesuffix(self, suffix: ReadableBuffer, /) -> bytearray: ...
def replace(self, old: ReadableBuffer, new: ReadableBuffer, count: SupportsIndex = -1, /) -> bytearray: ... def replace(self, old: ReadableBuffer, new: ReadableBuffer, count: SupportsIndex = -1, /) -> bytearray: ...
def rfind( def rfind(
self, sub: ReadableBuffer | SupportsIndex, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., / self, sub: ReadableBuffer | SupportsIndex, start: SupportsIndex | None = ..., end: SupportsIndex | None = ..., /
@ -1009,8 +999,7 @@ class tuple(Sequence[_T_co]):
def __rmul__(self, value: SupportsIndex, /) -> tuple[_T_co, ...]: ... def __rmul__(self, value: SupportsIndex, /) -> tuple[_T_co, ...]: ...
def count(self, value: Any, /) -> int: ... def count(self, value: Any, /) -> int: ...
def index(self, value: Any, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ... def index(self, value: Any, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
# Doesn't exist at runtime, but deleting this breaks mypy and pyright. See: # Doesn't exist at runtime, but deleting this breaks mypy and pyright. See:
# https://github.com/python/typeshed/issues/7580 # https://github.com/python/typeshed/issues/7580
@ -1092,8 +1081,7 @@ class list(MutableSequence[_T]):
def __lt__(self, value: list[_T], /) -> bool: ... def __lt__(self, value: list[_T], /) -> bool: ...
def __le__(self, value: list[_T], /) -> bool: ... def __le__(self, value: list[_T], /) -> bool: ...
def __eq__(self, value: object, /) -> bool: ... def __eq__(self, value: object, /) -> bool: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class dict(MutableMapping[_KT, _VT]): class dict(MutableMapping[_KT, _VT]):
# __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics # __init__ should be kept roughly in line with `collections.UserDict.__init__`, which has similar semantics
@ -1162,21 +1150,20 @@ class dict(MutableMapping[_KT, _VT]):
def __eq__(self, value: object, /) -> bool: ... def __eq__(self, value: object, /) -> bool: ...
def __reversed__(self) -> Iterator[_KT]: ... def __reversed__(self) -> Iterator[_KT]: ...
__hash__: ClassVar[None] # type: ignore[assignment] __hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... @overload
@overload def __or__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
def __or__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ... @overload
@overload def __or__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
def __or__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ... @overload
@overload def __ror__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ...
def __ror__(self, value: dict[_KT, _VT], /) -> dict[_KT, _VT]: ... @overload
@overload def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ...
def __ror__(self, value: dict[_T1, _T2], /) -> dict[_KT | _T1, _VT | _T2]: ... # dict.__ior__ should be kept roughly in line with MutableMapping.update()
# dict.__ior__ should be kept roughly in line with MutableMapping.update() @overload # type: ignore[misc]
@overload # type: ignore[misc] def __ior__(self, value: SupportsKeysAndGetItem[_KT, _VT], /) -> Self: ...
def __ior__(self, value: SupportsKeysAndGetItem[_KT, _VT], /) -> Self: ... @overload
@overload def __ior__(self, value: Iterable[tuple[_KT, _VT]], /) -> Self: ...
def __ior__(self, value: Iterable[tuple[_KT, _VT]], /) -> Self: ...
class set(MutableSet[_T]): class set(MutableSet[_T]):
@overload @overload
@ -1215,8 +1202,7 @@ class set(MutableSet[_T]):
def __gt__(self, value: AbstractSet[object], /) -> bool: ... def __gt__(self, value: AbstractSet[object], /) -> bool: ...
def __eq__(self, value: object, /) -> bool: ... def __eq__(self, value: object, /) -> bool: ...
__hash__: ClassVar[None] # type: ignore[assignment] __hash__: ClassVar[None] # type: ignore[assignment]
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class frozenset(AbstractSet[_T_co]): class frozenset(AbstractSet[_T_co]):
@overload @overload
@ -1244,15 +1230,13 @@ class frozenset(AbstractSet[_T_co]):
def __gt__(self, value: AbstractSet[object], /) -> bool: ... def __gt__(self, value: AbstractSet[object], /) -> bool: ...
def __eq__(self, value: object, /) -> bool: ... def __eq__(self, value: object, /) -> bool: ...
def __hash__(self) -> int: ... def __hash__(self) -> int: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class enumerate(Generic[_T]): class enumerate(Generic[_T]):
def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ... def __new__(cls, iterable: Iterable[_T], start: int = 0) -> Self: ...
def __iter__(self) -> Self: ... def __iter__(self) -> Self: ...
def __next__(self) -> tuple[int, _T]: ... def __next__(self) -> tuple[int, _T]: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
@final @final
class range(Sequence[int]): class range(Sequence[int]):
@ -1297,6 +1281,9 @@ class property:
def getter(self, fget: Callable[[Any], Any], /) -> property: ... def getter(self, fget: Callable[[Any], Any], /) -> property: ...
def setter(self, fset: Callable[[Any, Any], None], /) -> property: ... def setter(self, fset: Callable[[Any, Any], None], /) -> property: ...
def deleter(self, fdel: Callable[[Any], None], /) -> property: ... def deleter(self, fdel: Callable[[Any], None], /) -> property: ...
@overload
def __get__(self, instance: None, owner: type, /) -> Self: ...
@overload
def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ... def __get__(self, instance: Any, owner: type | None = None, /) -> Any: ...
def __set__(self, instance: Any, value: Any, /) -> None: ... def __set__(self, instance: Any, value: Any, /) -> None: ...
def __delete__(self, instance: Any, /) -> None: ... def __delete__(self, instance: Any, /) -> None: ...

View File

@ -1,10 +1,9 @@
import _compression import _compression
import sys
from _bz2 import BZ2Compressor as BZ2Compressor, BZ2Decompressor as BZ2Decompressor from _bz2 import BZ2Compressor as BZ2Compressor, BZ2Decompressor as BZ2Decompressor
from _compression import BaseStream from _compression import BaseStream
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
from collections.abc import Iterable from collections.abc import Iterable
from typing import IO, Any, Literal, Protocol, SupportsIndex, TextIO, overload from typing import IO, Literal, Protocol, SupportsIndex, TextIO, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
__all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "decompress"] __all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "decompress"]
@ -94,33 +93,14 @@ def open(
class BZ2File(BaseStream, IO[bytes]): class BZ2File(BaseStream, IO[bytes]):
def __enter__(self) -> Self: ... def __enter__(self) -> Self: ...
if sys.version_info >= (3, 9): @overload
@overload def __init__(self, filename: _WritableFileobj, mode: _WriteBinaryMode, *, compresslevel: int = 9) -> None: ...
def __init__(self, filename: _WritableFileobj, mode: _WriteBinaryMode, *, compresslevel: int = 9) -> None: ... @overload
@overload def __init__(self, filename: _ReadableFileobj, mode: _ReadBinaryMode = "r", *, compresslevel: int = 9) -> None: ...
def __init__(self, filename: _ReadableFileobj, mode: _ReadBinaryMode = "r", *, compresslevel: int = 9) -> None: ... @overload
@overload def __init__(
def __init__( self, filename: StrOrBytesPath, mode: _ReadBinaryMode | _WriteBinaryMode = "r", *, compresslevel: int = 9
self, filename: StrOrBytesPath, mode: _ReadBinaryMode | _WriteBinaryMode = "r", *, compresslevel: int = 9 ) -> None: ...
) -> None: ...
else:
@overload
def __init__(
self, filename: _WritableFileobj, mode: _WriteBinaryMode, buffering: Any | None = None, compresslevel: int = 9
) -> None: ...
@overload
def __init__(
self, filename: _ReadableFileobj, mode: _ReadBinaryMode = "r", buffering: Any | None = None, compresslevel: int = 9
) -> None: ...
@overload
def __init__(
self,
filename: StrOrBytesPath,
mode: _ReadBinaryMode | _WriteBinaryMode = "r",
buffering: Any | None = None,
compresslevel: int = 9,
) -> None: ...
def read(self, size: int | None = -1) -> bytes: ... def read(self, size: int | None = -1) -> bytes: ...
def read1(self, size: int = -1) -> bytes: ... def read1(self, size: int = -1) -> bytes: ...
def readline(self, size: SupportsIndex = -1) -> bytes: ... # type: ignore[override] def readline(self, size: SupportsIndex = -1) -> bytes: ... # type: ignore[override]

View File

@ -1,15 +1,15 @@
import sys import sys
from codeop import CommandCompiler from codeop import CommandCompiler
from collections.abc import Callable, Mapping from collections.abc import Callable
from types import CodeType from types import CodeType
from typing import Any from typing import Any
__all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact", "compile_command"] __all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact", "compile_command"]
class InteractiveInterpreter: class InteractiveInterpreter:
locals: Mapping[str, Any] # undocumented locals: dict[str, Any] # undocumented
compile: CommandCompiler # undocumented compile: CommandCompiler # undocumented
def __init__(self, locals: Mapping[str, Any] | None = None) -> None: ... def __init__(self, locals: dict[str, Any] | None = None) -> None: ...
def runsource(self, source: str, filename: str = "<input>", symbol: str = "single") -> bool: ... def runsource(self, source: str, filename: str = "<input>", symbol: str = "single") -> bool: ...
def runcode(self, code: CodeType) -> None: ... def runcode(self, code: CodeType) -> None: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
@ -25,11 +25,11 @@ class InteractiveConsole(InteractiveInterpreter):
filename: str # undocumented filename: str # undocumented
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def __init__( def __init__(
self, locals: Mapping[str, Any] | None = None, filename: str = "<console>", *, local_exit: bool = False self, locals: dict[str, Any] | None = None, filename: str = "<console>", *, local_exit: bool = False
) -> None: ... ) -> None: ...
def push(self, line: str, filename: str | None = None) -> bool: ... def push(self, line: str, filename: str | None = None) -> bool: ...
else: else:
def __init__(self, locals: Mapping[str, Any] | None = None, filename: str = "<console>") -> None: ... def __init__(self, locals: dict[str, Any] | None = None, filename: str = "<console>") -> None: ...
def push(self, line: str) -> bool: ... def push(self, line: str) -> bool: ...
def interact(self, banner: str | None = None, exitmsg: str | None = None) -> None: ... def interact(self, banner: str | None = None, exitmsg: str | None = None) -> None: ...
@ -40,7 +40,7 @@ if sys.version_info >= (3, 13):
def interact( def interact(
banner: str | None = None, banner: str | None = None,
readfunc: Callable[[str], str] | None = None, readfunc: Callable[[str], str] | None = None,
local: Mapping[str, Any] | None = None, local: dict[str, Any] | None = None,
exitmsg: str | None = None, exitmsg: str | None = None,
local_exit: bool = False, local_exit: bool = False,
) -> None: ... ) -> None: ...
@ -49,7 +49,7 @@ else:
def interact( def interact(
banner: str | None = None, banner: str | None = None,
readfunc: Callable[[str], str] | None = None, readfunc: Callable[[str], str] | None = None,
local: Mapping[str, Any] | None = None, local: dict[str, Any] | None = None,
exitmsg: str | None = None, exitmsg: str | None = None,
) -> None: ... ) -> None: ...

View File

@ -1,12 +1,10 @@
import sys import sys
from _collections_abc import dict_items, dict_keys, dict_values from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import SupportsItems, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT from _typeshed import SupportsItems, SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
from types import GenericAlias
from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload from typing import Any, ClassVar, Generic, NoReturn, SupportsIndex, TypeVar, final, overload
from typing_extensions import Self from typing_extensions import Self
if sys.version_info >= (3, 9):
from types import GenericAlias
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
from collections.abc import ( from collections.abc import (
Callable, Callable,
@ -93,20 +91,19 @@ class UserDict(MutableMapping[_KT, _VT]):
@classmethod @classmethod
@overload @overload
def fromkeys(cls, iterable: Iterable[_T], value: _S) -> UserDict[_T, _S]: ... def fromkeys(cls, iterable: Iterable[_T], value: _S) -> UserDict[_T, _S]: ...
if sys.version_info >= (3, 9): @overload
@overload def __or__(self, other: UserDict[_KT, _VT] | dict[_KT, _VT]) -> Self: ...
def __or__(self, other: UserDict[_KT, _VT] | dict[_KT, _VT]) -> Self: ... @overload
@overload def __or__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ...
def __or__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ... @overload
@overload def __ror__(self, other: UserDict[_KT, _VT] | dict[_KT, _VT]) -> Self: ...
def __ror__(self, other: UserDict[_KT, _VT] | dict[_KT, _VT]) -> Self: ... @overload
@overload def __ror__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ...
def __ror__(self, other: UserDict[_T1, _T2] | dict[_T1, _T2]) -> UserDict[_KT | _T1, _VT | _T2]: ... # UserDict.__ior__ should be kept roughly in line with MutableMapping.update()
# UserDict.__ior__ should be kept roughly in line with MutableMapping.update() @overload # type: ignore[misc]
@overload # type: ignore[misc] def __ior__(self, other: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ...
def __ior__(self, other: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ... @overload
@overload def __ior__(self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...
def __ior__(self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
@overload @overload
def get(self, key: _KT, default: None = None) -> _VT | None: ... def get(self, key: _KT, default: None = None) -> _VT | None: ...
@ -213,10 +210,8 @@ class UserString(Sequence[UserString]):
def lstrip(self, chars: str | None = None) -> Self: ... def lstrip(self, chars: str | None = None) -> Self: ...
maketrans = str.maketrans maketrans = str.maketrans
def partition(self, sep: str) -> tuple[str, str, str]: ... def partition(self, sep: str) -> tuple[str, str, str]: ...
if sys.version_info >= (3, 9): def removeprefix(self, prefix: str | UserString, /) -> Self: ...
def removeprefix(self, prefix: str | UserString, /) -> Self: ... def removesuffix(self, suffix: str | UserString, /) -> Self: ...
def removesuffix(self, suffix: str | UserString, /) -> Self: ...
def replace(self, old: str | UserString, new: str | UserString, maxsplit: int = -1) -> Self: ... def replace(self, old: str | UserString, new: str | UserString, maxsplit: int = -1) -> Self: ...
def rfind(self, sub: str | UserString, start: int = 0, end: int = sys.maxsize) -> int: ... def rfind(self, sub: str | UserString, start: int = 0, end: int = sys.maxsize) -> int: ...
def rindex(self, sub: str | UserString, start: int = 0, end: int = sys.maxsize) -> int: ... def rindex(self, sub: str | UserString, start: int = 0, end: int = sys.maxsize) -> int: ...
@ -271,8 +266,7 @@ class deque(MutableSequence[_T]):
def __gt__(self, value: deque[_T], /) -> bool: ... def __gt__(self, value: deque[_T], /) -> bool: ...
def __ge__(self, value: deque[_T], /) -> bool: ... def __ge__(self, value: deque[_T], /) -> bool: ...
def __eq__(self, value: object, /) -> bool: ... def __eq__(self, value: object, /) -> bool: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class Counter(dict[_T, int], Generic[_T]): class Counter(dict[_T, int], Generic[_T]):
@overload @overload
@ -387,15 +381,14 @@ class OrderedDict(dict[_KT, _VT]):
@overload @overload
def pop(self, key: _KT, default: _T) -> _VT | _T: ... def pop(self, key: _KT, default: _T) -> _VT | _T: ...
def __eq__(self, value: object, /) -> bool: ... def __eq__(self, value: object, /) -> bool: ...
if sys.version_info >= (3, 9): @overload
@overload def __or__(self, value: dict[_KT, _VT], /) -> Self: ...
def __or__(self, value: dict[_KT, _VT], /) -> Self: ... @overload
@overload def __or__(self, value: dict[_T1, _T2], /) -> OrderedDict[_KT | _T1, _VT | _T2]: ...
def __or__(self, value: dict[_T1, _T2], /) -> OrderedDict[_KT | _T1, _VT | _T2]: ... @overload
@overload def __ror__(self, value: dict[_KT, _VT], /) -> Self: ...
def __ror__(self, value: dict[_KT, _VT], /) -> Self: ... @overload
@overload def __ror__(self, value: dict[_T1, _T2], /) -> OrderedDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
def __ror__(self, value: dict[_T1, _T2], /) -> OrderedDict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
class defaultdict(dict[_KT, _VT]): class defaultdict(dict[_KT, _VT]):
default_factory: Callable[[], _VT] | None default_factory: Callable[[], _VT] | None
@ -435,15 +428,14 @@ class defaultdict(dict[_KT, _VT]):
def __missing__(self, key: _KT, /) -> _VT: ... def __missing__(self, key: _KT, /) -> _VT: ...
def __copy__(self) -> Self: ... def __copy__(self) -> Self: ...
def copy(self) -> Self: ... def copy(self) -> Self: ...
if sys.version_info >= (3, 9): @overload
@overload def __or__(self, value: dict[_KT, _VT], /) -> Self: ...
def __or__(self, value: dict[_KT, _VT], /) -> Self: ... @overload
@overload def __or__(self, value: dict[_T1, _T2], /) -> defaultdict[_KT | _T1, _VT | _T2]: ...
def __or__(self, value: dict[_T1, _T2], /) -> defaultdict[_KT | _T1, _VT | _T2]: ... @overload
@overload def __ror__(self, value: dict[_KT, _VT], /) -> Self: ...
def __ror__(self, value: dict[_KT, _VT], /) -> Self: ... @overload
@overload def __ror__(self, value: dict[_T1, _T2], /) -> defaultdict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
def __ror__(self, value: dict[_T1, _T2], /) -> defaultdict[_KT | _T1, _VT | _T2]: ... # type: ignore[misc]
class ChainMap(MutableMapping[_KT, _VT]): class ChainMap(MutableMapping[_KT, _VT]):
maps: list[MutableMapping[_KT, _VT]] maps: list[MutableMapping[_KT, _VT]]
@ -488,17 +480,16 @@ class ChainMap(MutableMapping[_KT, _VT]):
@classmethod @classmethod
@overload @overload
def fromkeys(cls, iterable: Iterable[_T], value: _S, /) -> ChainMap[_T, _S]: ... def fromkeys(cls, iterable: Iterable[_T], value: _S, /) -> ChainMap[_T, _S]: ...
if sys.version_info >= (3, 9): @overload
@overload def __or__(self, other: Mapping[_KT, _VT]) -> Self: ...
def __or__(self, other: Mapping[_KT, _VT]) -> Self: ... @overload
@overload def __or__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ...
def __or__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ... @overload
@overload def __ror__(self, other: Mapping[_KT, _VT]) -> Self: ...
def __ror__(self, other: Mapping[_KT, _VT]) -> Self: ... @overload
@overload def __ror__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ...
def __ror__(self, other: Mapping[_T1, _T2]) -> ChainMap[_KT | _T1, _VT | _T2]: ... # ChainMap.__ior__ should be kept roughly in line with MutableMapping.update()
# ChainMap.__ior__ should be kept roughly in line with MutableMapping.update() @overload # type: ignore[misc]
@overload # type: ignore[misc] def __ior__(self, other: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ...
def __ior__(self, other: SupportsKeysAndGetItem[_KT, _VT]) -> Self: ... @overload
@overload def __ior__(self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...
def __ior__(self, other: Iterable[tuple[_KT, _VT]]) -> Self: ...

View File

@ -7,7 +7,7 @@ def hls_to_rgb(h: float, l: float, s: float) -> tuple[float, float, float]: ...
def rgb_to_hsv(r: float, g: float, b: float) -> tuple[float, float, float]: ... def rgb_to_hsv(r: float, g: float, b: float) -> tuple[float, float, float]: ...
def hsv_to_rgb(h: float, s: float, v: float) -> tuple[float, float, float]: ... def hsv_to_rgb(h: float, s: float, v: float) -> tuple[float, float, float]: ...
# TODO undocumented # TODO: undocumented
ONE_SIXTH: float ONE_SIXTH: float
ONE_THIRD: float ONE_THIRD: float
TWO_THIRD: float TWO_THIRD: float

View File

@ -42,7 +42,7 @@ if sys.version_info >= (3, 10):
hardlink_dupes: bool = False, hardlink_dupes: bool = False,
) -> bool: ... ) -> bool: ...
elif sys.version_info >= (3, 9): else:
def compile_dir( def compile_dir(
dir: StrPath, dir: StrPath,
maxlevels: int | None = None, maxlevels: int | None = None,
@ -76,30 +76,6 @@ elif sys.version_info >= (3, 9):
hardlink_dupes: bool = False, hardlink_dupes: bool = False,
) -> bool: ... ) -> bool: ...
else:
def compile_dir(
dir: StrPath,
maxlevels: int = 10,
ddir: StrPath | None = None,
force: bool = False,
rx: _SupportsSearch | None = None,
quiet: int = 0,
legacy: bool = False,
optimize: int = -1,
workers: int = 1,
invalidation_mode: PycInvalidationMode | None = None,
) -> bool: ...
def compile_file(
fullname: StrPath,
ddir: StrPath | None = None,
force: bool = False,
rx: _SupportsSearch | None = None,
quiet: int = 0,
legacy: bool = False,
optimize: int = -1,
invalidation_mode: PycInvalidationMode | None = None,
) -> bool: ...
def compile_path( def compile_path(
skip_curdir: bool = ..., skip_curdir: bool = ...,
maxlevels: int = 0, maxlevels: int = 0,

View File

@ -1,15 +1,12 @@
import sys import sys
import threading import threading
from _typeshed import Unused from _typeshed import Unused
from collections.abc import Callable, Collection, Iterable, Iterator from collections.abc import Callable, Iterable, Iterator
from logging import Logger from logging import Logger
from types import TracebackType from types import GenericAlias, TracebackType
from typing import Any, Final, Generic, NamedTuple, Protocol, TypeVar from typing import Any, Final, Generic, NamedTuple, Protocol, TypeVar
from typing_extensions import ParamSpec, Self from typing_extensions import ParamSpec, Self
if sys.version_info >= (3, 9):
from types import GenericAlias
FIRST_COMPLETED: Final = "FIRST_COMPLETED" FIRST_COMPLETED: Final = "FIRST_COMPLETED"
FIRST_EXCEPTION: Final = "FIRST_EXCEPTION" FIRST_EXCEPTION: Final = "FIRST_EXCEPTION"
ALL_COMPLETED: Final = "ALL_COMPLETED" ALL_COMPLETED: Final = "ALL_COMPLETED"
@ -53,23 +50,14 @@ class Future(Generic[_T]):
def set_result(self, result: _T) -> None: ... def set_result(self, result: _T) -> None: ...
def exception(self, timeout: float | None = None) -> BaseException | None: ... def exception(self, timeout: float | None = None) -> BaseException | None: ...
def set_exception(self, exception: BaseException | None) -> None: ... def set_exception(self, exception: BaseException | None) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class Executor: class Executor:
if sys.version_info >= (3, 9): def submit(self, fn: Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]: ...
def submit(self, fn: Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]: ...
else:
def submit(self, fn: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> Future[_T]: ...
def map( def map(
self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: float | None = None, chunksize: int = 1 self, fn: Callable[..., _T], *iterables: Iterable[Any], timeout: float | None = None, chunksize: int = 1
) -> Iterator[_T]: ... ) -> Iterator[_T]: ...
if sys.version_info >= (3, 9): def shutdown(self, wait: bool = True, *, cancel_futures: bool = False) -> None: ...
def shutdown(self, wait: bool = True, *, cancel_futures: bool = False) -> None: ...
else:
def shutdown(self, wait: bool = True) -> None: ...
def __enter__(self) -> Self: ... def __enter__(self) -> Self: ...
def __exit__( def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
@ -91,15 +79,9 @@ class DoneAndNotDoneFutures(NamedTuple, Generic[_T]):
done: set[Future[_T]] done: set[Future[_T]]
not_done: set[Future[_T]] not_done: set[Future[_T]]
if sys.version_info >= (3, 9): def wait(
def wait( fs: Iterable[Future[_T]], timeout: float | None = None, return_when: str = "ALL_COMPLETED"
fs: Iterable[Future[_T]], timeout: float | None = None, return_when: str = "ALL_COMPLETED" ) -> DoneAndNotDoneFutures[_T]: ...
) -> DoneAndNotDoneFutures[_T]: ...
else:
def wait(
fs: Collection[Future[_T]], timeout: float | None = None, return_when: str = "ALL_COMPLETED"
) -> DoneAndNotDoneFutures[_T]: ...
class _Waiter: class _Waiter:
event: threading.Event event: threading.Event

View File

@ -84,7 +84,7 @@ class _SafeQueue(Queue[Future[Any]]):
pending_work_items: dict[int, _WorkItem[Any]], pending_work_items: dict[int, _WorkItem[Any]],
thread_wakeup: _ThreadWakeup, thread_wakeup: _ThreadWakeup,
) -> None: ... ) -> None: ...
elif sys.version_info >= (3, 9): else:
def __init__( def __init__(
self, self,
max_size: int | None = 0, max_size: int | None = 0,
@ -94,10 +94,6 @@ class _SafeQueue(Queue[Future[Any]]):
shutdown_lock: Lock, shutdown_lock: Lock,
thread_wakeup: _ThreadWakeup, thread_wakeup: _ThreadWakeup,
) -> None: ... ) -> None: ...
else:
def __init__(
self, max_size: int | None = 0, *, ctx: BaseContext, pending_work_items: dict[int, _WorkItem[Any]]
) -> None: ...
def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ... def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ...
@ -135,27 +131,26 @@ else:
initargs: tuple[Unpack[_Ts]], initargs: tuple[Unpack[_Ts]],
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 9): class _ExecutorManagerThread(Thread):
class _ExecutorManagerThread(Thread): thread_wakeup: _ThreadWakeup
thread_wakeup: _ThreadWakeup shutdown_lock: Lock
shutdown_lock: Lock executor_reference: ref[Any]
executor_reference: ref[Any] processes: MutableMapping[int, Process]
processes: MutableMapping[int, Process] call_queue: Queue[_CallItem]
call_queue: Queue[_CallItem] result_queue: SimpleQueue[_ResultItem]
result_queue: SimpleQueue[_ResultItem] work_ids_queue: Queue[int]
work_ids_queue: Queue[int] pending_work_items: dict[int, _WorkItem[Any]]
pending_work_items: dict[int, _WorkItem[Any]] def __init__(self, executor: ProcessPoolExecutor) -> None: ...
def __init__(self, executor: ProcessPoolExecutor) -> None: ... def run(self) -> None: ...
def run(self) -> None: ... def add_call_item_to_queue(self) -> None: ...
def add_call_item_to_queue(self) -> None: ... def wait_result_broken_or_wakeup(self) -> tuple[Any, bool, str]: ...
def wait_result_broken_or_wakeup(self) -> tuple[Any, bool, str]: ... def process_result_item(self, result_item: int | _ResultItem) -> None: ...
def process_result_item(self, result_item: int | _ResultItem) -> None: ... def is_shutting_down(self) -> bool: ...
def is_shutting_down(self) -> bool: ... def terminate_broken(self, cause: str) -> None: ...
def terminate_broken(self, cause: str) -> None: ... def flag_executor_shutting_down(self) -> None: ...
def flag_executor_shutting_down(self) -> None: ... def shutdown_workers(self) -> None: ...
def shutdown_workers(self) -> None: ... def join_executor_internals(self) -> None: ...
def join_executor_internals(self) -> None: ... def get_n_children_alive(self) -> int: ...
def get_n_children_alive(self) -> int: ...
_system_limits_checked: bool _system_limits_checked: bool
_system_limited: bool | None _system_limited: bool | None
@ -238,7 +233,6 @@ class ProcessPoolExecutor(Executor):
initializer: Callable[[Unpack[_Ts]], object], initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]], initargs: tuple[Unpack[_Ts]],
) -> None: ... ) -> None: ...
if sys.version_info >= (3, 9):
def _start_executor_manager_thread(self) -> None: ...
def _start_executor_manager_thread(self) -> None: ...
def _adjust_process_count(self) -> None: ... def _adjust_process_count(self) -> None: ...

View File

@ -1,7 +1,7 @@
import queue import queue
import sys
from collections.abc import Callable, Iterable, Mapping, Set as AbstractSet from collections.abc import Callable, Iterable, Mapping, Set as AbstractSet
from threading import Lock, Semaphore, Thread from threading import Lock, Semaphore, Thread
from types import GenericAlias
from typing import Any, Generic, TypeVar, overload from typing import Any, Generic, TypeVar, overload
from typing_extensions import TypeVarTuple, Unpack from typing_extensions import TypeVarTuple, Unpack
from weakref import ref from weakref import ref
@ -16,9 +16,6 @@ _global_shutdown_lock: Lock
def _python_exit() -> None: ... def _python_exit() -> None: ...
if sys.version_info >= (3, 9):
from types import GenericAlias
_S = TypeVar("_S") _S = TypeVar("_S")
class _WorkItem(Generic[_S]): class _WorkItem(Generic[_S]):
@ -28,8 +25,7 @@ class _WorkItem(Generic[_S]):
kwargs: Mapping[str, Any] kwargs: Mapping[str, Any]
def __init__(self, future: Future[_S], fn: Callable[..., _S], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ... def __init__(self, future: Future[_S], fn: Callable[..., _S], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
def run(self) -> None: ... def run(self) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def _worker( def _worker(
executor_reference: ref[Any], executor_reference: ref[Any],

View File

@ -81,14 +81,9 @@ class _GeneratorContextManager(
AbstractContextManager[_T_co, bool | None], AbstractContextManager[_T_co, bool | None],
ContextDecorator, ContextDecorator,
): ):
if sys.version_info >= (3, 9): def __exit__(
def __exit__( self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ...
) -> bool | None: ...
else:
def __exit__(
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ... def contextmanager(func: Callable[_P, Iterator[_T_co]]) -> Callable[_P, _GeneratorContextManager[_T_co]]: ...

View File

@ -26,12 +26,10 @@ else:
from _typeshed import SupportsWrite from _typeshed import SupportsWrite
from collections.abc import Collection, Iterable, Mapping, Sequence from collections.abc import Collection, Iterable, Mapping, Sequence
from types import GenericAlias
from typing import Any, Generic, Literal, TypeVar, overload from typing import Any, Generic, Literal, TypeVar, overload
from typing_extensions import Self from typing_extensions import Self
if sys.version_info >= (3, 12):
from types import GenericAlias
__all__ = [ __all__ = [
"QUOTE_MINIMAL", "QUOTE_MINIMAL",
"QUOTE_ALL", "QUOTE_ALL",

View File

@ -26,7 +26,8 @@ from _ctypes import (
) )
from _typeshed import StrPath from _typeshed import StrPath
from ctypes._endian import BigEndianStructure as BigEndianStructure, LittleEndianStructure as LittleEndianStructure from ctypes._endian import BigEndianStructure as BigEndianStructure, LittleEndianStructure as LittleEndianStructure
from typing import Any, ClassVar, Generic, TypeVar, type_check_only from types import GenericAlias
from typing import Any, ClassVar, Generic, Literal, TypeVar, type_check_only
from typing_extensions import Self, TypeAlias, deprecated from typing_extensions import Self, TypeAlias, deprecated
if sys.platform == "win32": if sys.platform == "win32":
@ -35,10 +36,7 @@ if sys.platform == "win32":
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from ctypes._endian import BigEndianUnion as BigEndianUnion, LittleEndianUnion as LittleEndianUnion from ctypes._endian import BigEndianUnion as BigEndianUnion, LittleEndianUnion as LittleEndianUnion
if sys.version_info >= (3, 9): _T = TypeVar("_T", default=Any)
from types import GenericAlias
_T = TypeVar("_T")
_DLLT = TypeVar("_DLLT", bound=CDLL) _DLLT = TypeVar("_DLLT", bound=CDLL)
_CT = TypeVar("_CT", bound=_CData) _CT = TypeVar("_CT", bound=_CData)
@ -92,8 +90,7 @@ class LibraryLoader(Generic[_DLLT]):
def __getattr__(self, name: str) -> _DLLT: ... def __getattr__(self, name: str) -> _DLLT: ...
def __getitem__(self, name: str) -> _DLLT: ... def __getitem__(self, name: str) -> _DLLT: ...
def LoadLibrary(self, name: str) -> _DLLT: ... def LoadLibrary(self, name: str) -> _DLLT: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
cdll: LibraryLoader[CDLL] cdll: LibraryLoader[CDLL]
if sys.platform == "win32": if sys.platform == "win32":
@ -151,14 +148,12 @@ c_buffer = create_string_buffer
def create_unicode_buffer(init: int | str, size: int | None = None) -> Array[c_wchar]: ... def create_unicode_buffer(init: int | str, size: int | None = None) -> Array[c_wchar]: ...
@deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15") @deprecated("Deprecated in Python 3.13; removal scheduled for Python 3.15")
def SetPointerType( def SetPointerType(pointer: type[_Pointer[Any]], cls: Any) -> None: ... # noqa: F811
pointer: type[_Pointer[Any]], cls: Any # noqa: F811 # Redefinition of unused `pointer` from line 22
) -> None: ...
def ARRAY(typ: _CT, len: int) -> Array[_CT]: ... # Soft Deprecated, no plans to remove def ARRAY(typ: _CT, len: int) -> Array[_CT]: ... # Soft Deprecated, no plans to remove
if sys.platform == "win32": if sys.platform == "win32":
def DllCanUnloadNow() -> int: ... def DllCanUnloadNow() -> int: ...
def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO not documented def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO: not documented
# Actually just an instance of _NamedFuncPointer (aka _CDLLFuncPointer), # Actually just an instance of _NamedFuncPointer (aka _CDLLFuncPointer),
# but we want to set a more specific __call__ # but we want to set a more specific __call__
@ -191,73 +186,121 @@ if sys.platform == "win32":
def wstring_at(ptr: _CVoidConstPLike, size: int = -1) -> str: ... def wstring_at(ptr: _CVoidConstPLike, size: int = -1) -> str: ...
class c_byte(_SimpleCData[int]): ... class py_object(_CanCastTo, _SimpleCData[_T]):
_type_: ClassVar[Literal["O"]]
class c_bool(_SimpleCData[bool]):
_type_: ClassVar[Literal["?"]]
def __init__(self, value: bool = ...) -> None: ...
class c_byte(_SimpleCData[int]):
_type_: ClassVar[Literal["b"]]
class c_ubyte(_SimpleCData[int]):
_type_: ClassVar[Literal["B"]]
class c_short(_SimpleCData[int]):
_type_: ClassVar[Literal["h"]]
class c_ushort(_SimpleCData[int]):
_type_: ClassVar[Literal["H"]]
class c_long(_SimpleCData[int]):
_type_: ClassVar[Literal["l"]]
class c_ulong(_SimpleCData[int]):
_type_: ClassVar[Literal["L"]]
class c_int(_SimpleCData[int]): # can be an alias for c_long
_type_: ClassVar[Literal["i", "l"]]
class c_uint(_SimpleCData[int]): # can be an alias for c_ulong
_type_: ClassVar[Literal["I", "L"]]
class c_longlong(_SimpleCData[int]): # can be an alias for c_long
_type_: ClassVar[Literal["q", "l"]]
class c_ulonglong(_SimpleCData[int]): # can be an alias for c_ulong
_type_: ClassVar[Literal["Q", "L"]]
c_int8 = c_byte
c_uint8 = c_ubyte
class c_int16(_SimpleCData[int]): # can be an alias for c_short or c_int
_type_: ClassVar[Literal["h", "i"]]
class c_uint16(_SimpleCData[int]): # can be an alias for c_ushort or c_uint
_type_: ClassVar[Literal["H", "I"]]
class c_int32(_SimpleCData[int]): # can be an alias for c_int or c_long
_type_: ClassVar[Literal["i", "l"]]
class c_uint32(_SimpleCData[int]): # can be an alias for c_uint or c_ulong
_type_: ClassVar[Literal["I", "L"]]
class c_int64(_SimpleCData[int]): # can be an alias for c_long or c_longlong
_type_: ClassVar[Literal["l", "q"]]
class c_uint64(_SimpleCData[int]): # can be an alias for c_ulong or c_ulonglong
_type_: ClassVar[Literal["L", "Q"]]
class c_ssize_t(_SimpleCData[int]): # alias for c_int, c_long, or c_longlong
_type_: ClassVar[Literal["i", "l", "q"]]
class c_size_t(_SimpleCData[int]): # alias for c_uint, c_ulong, or c_ulonglong
_type_: ClassVar[Literal["I", "L", "Q"]]
class c_float(_SimpleCData[float]):
_type_: ClassVar[Literal["f"]]
class c_double(_SimpleCData[float]):
_type_: ClassVar[Literal["d"]]
class c_longdouble(_SimpleCData[float]): # can be an alias for c_double
_type_: ClassVar[Literal["d", "g"]]
if sys.version_info >= (3, 14):
class c_float_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["E"]]
class c_double_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["C"]]
class c_longdouble_complex(_SimpleCData[complex]):
_type_: ClassVar[Literal["F"]]
class c_char(_SimpleCData[bytes]): class c_char(_SimpleCData[bytes]):
_type_: ClassVar[Literal["c"]]
def __init__(self, value: int | bytes | bytearray = ...) -> None: ... def __init__(self, value: int | bytes | bytearray = ...) -> None: ...
class c_char_p(_PointerLike, _SimpleCData[bytes | None]): class c_char_p(_PointerLike, _SimpleCData[bytes | None]):
_type_: ClassVar[Literal["z"]]
def __init__(self, value: int | bytes | None = ...) -> None: ... def __init__(self, value: int | bytes | None = ...) -> None: ...
@classmethod @classmethod
def from_param(cls, value: Any, /) -> Self | _CArgObject: ... def from_param(cls, value: Any, /) -> Self | _CArgObject: ...
class c_double(_SimpleCData[float]): ...
class c_longdouble(_SimpleCData[float]): ... # can be an alias for c_double
class c_float(_SimpleCData[float]): ...
class c_int(_SimpleCData[int]): ... # can be an alias for c_long
class c_long(_SimpleCData[int]): ...
class c_longlong(_SimpleCData[int]): ... # can be an alias for c_long
class c_short(_SimpleCData[int]): ...
class c_size_t(_SimpleCData[int]): ... # alias for c_uint, c_ulong, or c_ulonglong
class c_ssize_t(_SimpleCData[int]): ... # alias for c_int, c_long, or c_longlong
class c_ubyte(_SimpleCData[int]): ...
class c_uint(_SimpleCData[int]): ... # can be an alias for c_ulong
class c_ulong(_SimpleCData[int]): ...
class c_ulonglong(_SimpleCData[int]): ... # can be an alias for c_ulong
class c_ushort(_SimpleCData[int]): ...
class c_void_p(_PointerLike, _SimpleCData[int | None]): class c_void_p(_PointerLike, _SimpleCData[int | None]):
_type_: ClassVar[Literal["P"]]
@classmethod @classmethod
def from_param(cls, value: Any, /) -> Self | _CArgObject: ... def from_param(cls, value: Any, /) -> Self | _CArgObject: ...
c_voidp = c_void_p # backwards compatibility (to a bug) c_voidp = c_void_p # backwards compatibility (to a bug)
class c_wchar(_SimpleCData[str]): ... class c_wchar(_SimpleCData[str]):
_type_: ClassVar[Literal["u"]]
c_int8 = c_byte
# these are actually dynamic aliases for c_short, c_int, c_long, or c_longlong
class c_int16(_SimpleCData[int]): ...
class c_int32(_SimpleCData[int]): ...
class c_int64(_SimpleCData[int]): ...
c_uint8 = c_ubyte
# these are actually dynamic aliases for c_ushort, c_uint, c_ulong, or c_ulonglong
class c_uint16(_SimpleCData[int]): ...
class c_uint32(_SimpleCData[int]): ...
class c_uint64(_SimpleCData[int]): ...
class c_wchar_p(_PointerLike, _SimpleCData[str | None]): class c_wchar_p(_PointerLike, _SimpleCData[str | None]):
_type_: ClassVar[Literal["Z"]]
def __init__(self, value: int | str | None = ...) -> None: ... def __init__(self, value: int | str | None = ...) -> None: ...
@classmethod @classmethod
def from_param(cls, value: Any, /) -> Self | _CArgObject: ... def from_param(cls, value: Any, /) -> Self | _CArgObject: ...
class c_bool(_SimpleCData[bool]):
def __init__(self, value: bool = ...) -> None: ...
if sys.platform == "win32": if sys.platform == "win32":
class HRESULT(_SimpleCData[int]): ... # TODO undocumented class HRESULT(_SimpleCData[int]): # TODO: undocumented
_type_: ClassVar[Literal["l"]]
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
# At runtime, this is an alias for either c_int32 or c_int64, # At runtime, this is an alias for either c_int32 or c_int64,
# which are themselves an alias for one of c_short, c_int, c_long, or c_longlong # which are themselves an alias for one of c_int, c_long, or c_longlong
# This covers all our bases. # This covers all our bases.
c_time_t: type[c_int32 | c_int64 | c_short | c_int | c_long | c_longlong] c_time_t: type[c_int32 | c_int64 | c_int | c_long | c_longlong]
class py_object(_CanCastTo, _SimpleCData[_T]): ...
if sys.version_info >= (3, 14):
class c_float_complex(_SimpleCData[complex]): ...
class c_double_complex(_SimpleCData[complex]): ...
class c_longdouble_complex(_SimpleCData[complex]): ...

View File

@ -1,10 +1,10 @@
import sys
from _ctypes import _CArgObject, _CField from _ctypes import _CArgObject, _CField
from ctypes import ( from ctypes import (
Array, Array,
Structure, Structure,
_Pointer, _Pointer,
_SimpleCData, _SimpleCData,
c_byte,
c_char, c_char,
c_char_p, c_char_p,
c_double, c_double,
@ -24,7 +24,15 @@ from ctypes import (
from typing import Any, TypeVar from typing import Any, TypeVar
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
BYTE = c_byte if sys.version_info >= (3, 12):
from ctypes import c_ubyte
BYTE = c_ubyte
else:
from ctypes import c_byte
BYTE = c_byte
WORD = c_ushort WORD = c_ushort
DWORD = c_ulong DWORD = c_ulong
CHAR = c_char CHAR = c_char

View File

@ -4,11 +4,9 @@ import types
from _typeshed import DataclassInstance from _typeshed import DataclassInstance
from builtins import type as Type # alias to avoid name clashes with fields named "type" from builtins import type as Type # alias to avoid name clashes with fields named "type"
from collections.abc import Callable, Iterable, Mapping from collections.abc import Callable, Iterable, Mapping
from types import GenericAlias
from typing import Any, Generic, Literal, Protocol, TypeVar, overload from typing import Any, Generic, Literal, Protocol, TypeVar, overload
from typing_extensions import Never, TypeAlias, TypeIs from typing_extensions import Never, TypeIs
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T") _T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True) _T_co = TypeVar("_T_co", covariant=True)
@ -142,8 +140,7 @@ class Field(Generic[_T]):
) -> None: ... ) -> None: ...
def __set_name__(self, owner: Type[Any], name: str) -> None: ... def __set_name__(self, owner: Type[Any], name: str) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
# NOTE: Actual return type is 'Field[_T]', but we want to help type checkers # NOTE: Actual return type is 'Field[_T]', but we want to help type checkers
# to understand the magic that happens at runtime. # to understand the magic that happens at runtime.
@ -232,22 +229,13 @@ def is_dataclass(obj: object) -> TypeIs[DataclassInstance | type[DataclassInstan
class FrozenInstanceError(AttributeError): ... class FrozenInstanceError(AttributeError): ...
if sys.version_info >= (3, 9): class InitVar(Generic[_T], metaclass=type):
_InitVarMeta: TypeAlias = type
else:
class _InitVarMeta(type):
# Not used, instead `InitVar.__class_getitem__` is called.
# pyright (not unreasonably) thinks this is an invalid use of InitVar.
def __getitem__(self, params: Any) -> InitVar[Any]: ... # pyright: ignore[reportInvalidTypeForm]
class InitVar(Generic[_T], metaclass=_InitVarMeta):
type: Type[_T] type: Type[_T]
def __init__(self, type: Type[_T]) -> None: ... def __init__(self, type: Type[_T]) -> None: ...
if sys.version_info >= (3, 9): @overload
@overload def __class_getitem__(cls, type: Type[_T]) -> InitVar[_T]: ... # pyright: ignore[reportInvalidTypeForm]
def __class_getitem__(cls, type: Type[_T]) -> InitVar[_T]: ... # pyright: ignore[reportInvalidTypeForm] @overload
@overload def __class_getitem__(cls, type: Any) -> InitVar[Any]: ... # pyright: ignore[reportInvalidTypeForm]
def __class_getitem__(cls, type: Any) -> InitVar[Any]: ... # pyright: ignore[reportInvalidTypeForm]
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
def make_dataclass( def make_dataclass(

View File

@ -6,7 +6,7 @@ from typing_extensions import CapsuleType, Self, TypeAlias, deprecated
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR", "UTC") __all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR", "UTC")
elif sys.version_info >= (3, 9): else:
__all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR") __all__ = ("date", "datetime", "time", "timedelta", "timezone", "tzinfo", "MINYEAR", "MAXYEAR")
MINYEAR: Final = 1 MINYEAR: Final = 1
@ -39,18 +39,17 @@ class timezone(tzinfo):
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
UTC: timezone UTC: timezone
if sys.version_info >= (3, 9): # This class calls itself datetime.IsoCalendarDate. It's neither
# This class calls itself datetime.IsoCalendarDate. It's neither # NamedTuple nor structseq.
# NamedTuple nor structseq. @final
@final @type_check_only
@type_check_only class _IsoCalendarDate(tuple[int, int, int]):
class _IsoCalendarDate(tuple[int, int, int]): @property
@property def year(self) -> int: ...
def year(self) -> int: ... @property
@property def week(self) -> int: ...
def week(self) -> int: ... @property
@property def weekday(self) -> int: ...
def weekday(self) -> int: ...
class date: class date:
min: ClassVar[date] min: ClassVar[date]
@ -106,10 +105,7 @@ class date:
def __hash__(self) -> int: ... def __hash__(self) -> int: ...
def weekday(self) -> int: ... def weekday(self) -> int: ...
def isoweekday(self) -> int: ... def isoweekday(self) -> int: ...
if sys.version_info >= (3, 9): def isocalendar(self) -> _IsoCalendarDate: ...
def isocalendar(self) -> _IsoCalendarDate: ...
else:
def isocalendar(self) -> tuple[int, int, int]: ...
class time: class time:
min: ClassVar[time] min: ClassVar[time]

View File

@ -1,10 +1,7 @@
import sys
from collections.abc import Callable, Iterable, Iterator, Sequence from collections.abc import Callable, Iterable, Iterator, Sequence
from types import GenericAlias
from typing import Any, AnyStr, Generic, Literal, NamedTuple, TypeVar, overload from typing import Any, AnyStr, Generic, Literal, NamedTuple, TypeVar, overload
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [ __all__ = [
"get_close_matches", "get_close_matches",
"ndiff", "ndiff",
@ -43,19 +40,14 @@ class SequenceMatcher(Generic[_T]):
def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ... def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ...
def set_seq1(self, a: Sequence[_T]) -> None: ... def set_seq1(self, a: Sequence[_T]) -> None: ...
def set_seq2(self, b: Sequence[_T]) -> None: ... def set_seq2(self, b: Sequence[_T]) -> None: ...
if sys.version_info >= (3, 9): def find_longest_match(self, alo: int = 0, ahi: int | None = None, blo: int = 0, bhi: int | None = None) -> Match: ...
def find_longest_match(self, alo: int = 0, ahi: int | None = None, blo: int = 0, bhi: int | None = None) -> Match: ...
else:
def find_longest_match(self, alo: int, ahi: int, blo: int, bhi: int) -> Match: ...
def get_matching_blocks(self) -> list[Match]: ... def get_matching_blocks(self) -> list[Match]: ...
def get_opcodes(self) -> list[tuple[Literal["replace", "delete", "insert", "equal"], int, int, int, int]]: ... def get_opcodes(self) -> list[tuple[Literal["replace", "delete", "insert", "equal"], int, int, int, int]]: ...
def get_grouped_opcodes(self, n: int = 3) -> Iterable[list[tuple[str, int, int, int, int]]]: ... def get_grouped_opcodes(self, n: int = 3) -> Iterable[list[tuple[str, int, int, int, int]]]: ...
def ratio(self) -> float: ... def ratio(self) -> float: ...
def quick_ratio(self) -> float: ... def quick_ratio(self) -> float: ...
def real_quick_ratio(self) -> float: ... def real_quick_ratio(self) -> float: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
@overload @overload
def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], n: int = 3, cutoff: float = 0.6) -> list[AnyStr]: ... def get_close_matches(word: AnyStr, possibilities: Iterable[AnyStr], n: int = 3, cutoff: float = 0.6) -> list[AnyStr]: ...

View File

@ -21,8 +21,7 @@ if sys.platform == "win32":
boolean_options: ClassVar[list[str]] boolean_options: ClassVar[list[str]]
all_versions: Incomplete all_versions: Incomplete
other_version: str other_version: str
if sys.version_info >= (3, 9): def __init__(self, *args, **kw) -> None: ...
def __init__(self, *args, **kw) -> None: ...
bdist_dir: Incomplete bdist_dir: Incomplete
plat_name: Incomplete plat_name: Incomplete
keep_temp: int keep_temp: int

View File

@ -13,7 +13,7 @@ longopt_xlate: Final[dict[int, int]]
class FancyGetopt: class FancyGetopt:
def __init__(self, option_table: list[_Option] | None = None) -> None: ... def __init__(self, option_table: list[_Option] | None = None) -> None: ...
# TODO kinda wrong, `getopt(object=object())` is invalid # TODO: kinda wrong, `getopt(object=object())` is invalid
@overload @overload
def getopt( def getopt(
self, args: _SliceableT[_StrSequenceT_co] | None = None, object: None = None self, args: _SliceableT[_StrSequenceT_co] | None = None, object: None = None

View File

@ -1,2 +0,0 @@
from _dummy_threading import *
from _dummy_threading import __all__ as __all__

View File

@ -22,7 +22,8 @@ NLSET: Final[set[str]]
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5 # Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
SPECIALSNL: Final[set[str]] SPECIALSNL: Final[set[str]]
if sys.version_info >= (3, 12): if sys.version_info >= (3, 10):
# Added in Python 3.10.17, 3.11.12, 3.12.9, 3.13.2 (may still be backported to 3.9)
def make_quoted_pairs(value: Any) -> str: ... def make_quoted_pairs(value: Any) -> str: ...
def quote_string(value: Any) -> str: ... def quote_string(value: Any) -> str: ...
@ -349,7 +350,7 @@ ListSeparator: Final[ValueTerminal]
RouteComponentMarker: Final[ValueTerminal] RouteComponentMarker: Final[ValueTerminal]
def get_fws(value: str) -> tuple[WhiteSpaceTerminal, str]: ... def get_fws(value: str) -> tuple[WhiteSpaceTerminal, str]: ...
def get_encoded_word(value: str) -> tuple[EncodedWord, str]: ... def get_encoded_word(value: str, terminal_type: str = "vtext") -> tuple[EncodedWord, str]: ...
def get_unstructured(value: str) -> UnstructuredTokenList: ... def get_unstructured(value: str) -> UnstructuredTokenList: ...
def get_qp_ctext(value: str) -> tuple[WhiteSpaceTerminal, str]: ... def get_qp_ctext(value: str) -> tuple[WhiteSpaceTerminal, str]: ...
def get_qcontent(value: str) -> tuple[ValueTerminal, str]: ... def get_qcontent(value: str) -> tuple[ValueTerminal, str]: ...

View File

@ -1,21 +0,0 @@
import codecs
from _codecs import _EncodingMap
from _typeshed import ReadableBuffer
class Codec(codecs.Codec):
def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ...
def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ...
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input: str, final: bool = False) -> bytes: ...
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input: ReadableBuffer, final: bool = False) -> str: ...
class StreamWriter(Codec, codecs.StreamWriter): ...
class StreamReader(Codec, codecs.StreamReader): ...
def getregentry() -> codecs.CodecInfo: ...
decoding_table: str
encoding_table: _EncodingMap

View File

@ -1,5 +1,4 @@
import codecs import codecs
import sys
from _typeshed import ReadableBuffer from _typeshed import ReadableBuffer
class Codec(codecs.Codec): class Codec(codecs.Codec):
@ -7,28 +6,18 @@ class Codec(codecs.Codec):
@staticmethod @staticmethod
def encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
# At runtime, this is codecs.raw_unicode_escape_decode # At runtime, this is codecs.raw_unicode_escape_decode
if sys.version_info >= (3, 9): @staticmethod
@staticmethod def decode(data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /) -> tuple[str, int]: ...
def decode(data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /) -> tuple[str, int]: ...
else:
@staticmethod
def decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
class IncrementalEncoder(codecs.IncrementalEncoder): class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input: str, final: bool = False) -> bytes: ... def encode(self, input: str, final: bool = False) -> bytes: ...
if sys.version_info >= (3, 9): class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
class IncrementalDecoder(codecs.BufferedIncrementalDecoder): def _buffer_decode(self, input: str | ReadableBuffer, errors: str | None, final: bool) -> tuple[str, int]: ...
def _buffer_decode(self, input: str | ReadableBuffer, errors: str | None, final: bool) -> tuple[str, int]: ...
else:
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input: str | ReadableBuffer, final: bool = False) -> str: ...
class StreamWriter(Codec, codecs.StreamWriter): ... class StreamWriter(Codec, codecs.StreamWriter): ...
class StreamReader(Codec, codecs.StreamReader): class StreamReader(Codec, codecs.StreamReader):
if sys.version_info >= (3, 9): def decode(self, input: str | ReadableBuffer, errors: str = "strict") -> tuple[str, int]: ... # type: ignore[override]
def decode(self, input: str | ReadableBuffer, errors: str = "strict") -> tuple[str, int]: ... # type: ignore[override]
def getregentry() -> codecs.CodecInfo: ... def getregentry() -> codecs.CodecInfo: ...

View File

@ -1,5 +1,4 @@
import codecs import codecs
import sys
from _typeshed import ReadableBuffer from _typeshed import ReadableBuffer
class Codec(codecs.Codec): class Codec(codecs.Codec):
@ -7,28 +6,18 @@ class Codec(codecs.Codec):
@staticmethod @staticmethod
def encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... def encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
# At runtime, this is codecs.unicode_escape_decode # At runtime, this is codecs.unicode_escape_decode
if sys.version_info >= (3, 9): @staticmethod
@staticmethod def decode(data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /) -> tuple[str, int]: ...
def decode(data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /) -> tuple[str, int]: ...
else:
@staticmethod
def decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
class IncrementalEncoder(codecs.IncrementalEncoder): class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input: str, final: bool = False) -> bytes: ... def encode(self, input: str, final: bool = False) -> bytes: ...
if sys.version_info >= (3, 9): class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
class IncrementalDecoder(codecs.BufferedIncrementalDecoder): def _buffer_decode(self, input: str | ReadableBuffer, errors: str | None, final: bool) -> tuple[str, int]: ...
def _buffer_decode(self, input: str | ReadableBuffer, errors: str | None, final: bool) -> tuple[str, int]: ...
else:
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input: str | ReadableBuffer, final: bool = False) -> str: ...
class StreamWriter(Codec, codecs.StreamWriter): ... class StreamWriter(Codec, codecs.StreamWriter): ...
class StreamReader(Codec, codecs.StreamReader): class StreamReader(Codec, codecs.StreamReader):
if sys.version_info >= (3, 9): def decode(self, input: str | ReadableBuffer, errors: str = "strict") -> tuple[str, int]: ... # type: ignore[override]
def decode(self, input: str | ReadableBuffer, errors: str = "strict") -> tuple[str, int]: ... # type: ignore[override]
def getregentry() -> codecs.CodecInfo: ... def getregentry() -> codecs.CodecInfo: ...

View File

@ -100,20 +100,13 @@ class EnumMeta(type):
_simple: bool = False, _simple: bool = False,
**kwds: Any, **kwds: Any,
) -> _typeshed.Self: ... ) -> _typeshed.Self: ...
elif sys.version_info >= (3, 9): else:
def __new__( def __new__(
metacls: type[_typeshed.Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any metacls: type[_typeshed.Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any
) -> _typeshed.Self: ... ) -> _typeshed.Self: ...
else:
def __new__(metacls: type[_typeshed.Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> _typeshed.Self: ...
if sys.version_info >= (3, 9):
@classmethod
def __prepare__(metacls, cls: str, bases: tuple[type, ...], **kwds: Any) -> _EnumDict: ... # type: ignore[override]
else:
@classmethod
def __prepare__(metacls, cls: str, bases: tuple[type, ...]) -> _EnumDict: ... # type: ignore[override]
@classmethod
def __prepare__(metacls, cls: str, bases: tuple[type, ...], **kwds: Any) -> _EnumDict: ... # type: ignore[override]
def __iter__(self: type[_EnumMemberT]) -> Iterator[_EnumMemberT]: ... def __iter__(self: type[_EnumMemberT]) -> Iterator[_EnumMemberT]: ...
def __reversed__(self: type[_EnumMemberT]) -> Iterator[_EnumMemberT]: ... def __reversed__(self: type[_EnumMemberT]) -> Iterator[_EnumMemberT]: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):

View File

@ -26,8 +26,7 @@ if sys.platform != "win32":
if sys.platform == "darwin": if sys.platform == "darwin":
F_FULLFSYNC: int F_FULLFSYNC: int
F_NOCACHE: int F_NOCACHE: int
if sys.version_info >= (3, 9): F_GETPATH: int
F_GETPATH: int
if sys.platform == "linux": if sys.platform == "linux":
F_SETLKW64: int F_SETLKW64: int
F_SETSIG: int F_SETSIG: int
@ -43,10 +42,9 @@ if sys.platform != "win32":
F_SEAL_SEAL: int F_SEAL_SEAL: int
F_SEAL_SHRINK: int F_SEAL_SHRINK: int
F_SEAL_WRITE: int F_SEAL_WRITE: int
if sys.version_info >= (3, 9): F_OFD_GETLK: Final[int]
F_OFD_GETLK: Final[int] F_OFD_SETLK: Final[int]
F_OFD_SETLK: Final[int] F_OFD_SETLKW: Final[int]
F_OFD_SETLKW: Final[int]
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
F_GETPIPE_SZ: int F_GETPIPE_SZ: int

View File

@ -1,11 +1,9 @@
import sys import sys
from _typeshed import GenericPath, StrOrBytesPath from _typeshed import GenericPath, StrOrBytesPath
from collections.abc import Callable, Iterable, Sequence from collections.abc import Callable, Iterable, Sequence
from types import GenericAlias
from typing import Any, AnyStr, Final, Generic, Literal from typing import Any, AnyStr, Final, Generic, Literal
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ["clear_cache", "cmp", "dircmp", "cmpfiles", "DEFAULT_IGNORES"] __all__ = ["clear_cache", "cmp", "dircmp", "cmpfiles", "DEFAULT_IGNORES"]
DEFAULT_IGNORES: list[str] DEFAULT_IGNORES: list[str]
@ -62,7 +60,6 @@ class dircmp(Generic[AnyStr]):
def phase3(self) -> None: ... def phase3(self) -> None: ...
def phase4(self) -> None: ... def phase4(self) -> None: ...
def phase4_closure(self) -> None: ... def phase4_closure(self) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def clear_cache() -> None: ... def clear_cache() -> None: ...

View File

@ -1,13 +1,10 @@
import sys import sys
from _typeshed import AnyStr_co, StrOrBytesPath from _typeshed import AnyStr_co, StrOrBytesPath
from collections.abc import Callable, Iterable from collections.abc import Callable, Iterable
from types import TracebackType from types import GenericAlias, TracebackType
from typing import IO, Any, AnyStr, Generic, Literal, Protocol, overload from typing import IO, Any, AnyStr, Generic, Literal, Protocol, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [ __all__ = [
"input", "input",
"close", "close",
@ -199,8 +196,7 @@ class FileInput(Generic[AnyStr]):
def fileno(self) -> int: ... def fileno(self) -> int: ...
def isfirstline(self) -> bool: ... def isfirstline(self) -> bool: ...
def isstdin(self) -> bool: ... def isstdin(self) -> bool: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
def hook_compressed( def hook_compressed(

View File

@ -1,24 +1,13 @@
import sys import sys
from collections.abc import Callable from collections.abc import Callable
from decimal import Decimal from decimal import Decimal
from numbers import Integral, Rational, Real from numbers import Rational, Real
from typing import Any, Literal, Protocol, SupportsIndex, overload from typing import Any, Literal, Protocol, SupportsIndex, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
_ComparableNum: TypeAlias = int | float | Decimal | Real _ComparableNum: TypeAlias = int | float | Decimal | Real
if sys.version_info >= (3, 9): __all__ = ["Fraction"]
__all__ = ["Fraction"]
else:
__all__ = ["Fraction", "gcd"]
@overload
def gcd(a: int, b: int) -> int: ...
@overload
def gcd(a: Integral, b: int) -> Integral: ...
@overload
def gcd(a: int, b: Integral) -> Integral: ...
@overload
def gcd(a: Integral, b: Integral) -> Integral: ...
class _ConvertibleToIntegerRatio(Protocol): class _ConvertibleToIntegerRatio(Protocol):
def as_integer_ratio(self) -> tuple[int | Rational, int | Rational]: ... def as_integer_ratio(self) -> tuple[int | Rational, int | Rational]: ...

View File

@ -41,29 +41,17 @@ class FTP:
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ... ) -> None: ...
source_address: tuple[str, int] | None source_address: tuple[str, int] | None
if sys.version_info >= (3, 9): def __init__(
def __init__( self,
self, host: str = "",
host: str = "", user: str = "",
user: str = "", passwd: str = "",
passwd: str = "", acct: str = "",
acct: str = "", timeout: float | None = ...,
timeout: float | None = ..., source_address: tuple[str, int] | None = None,
source_address: tuple[str, int] | None = None, *,
*, encoding: str = "utf-8",
encoding: str = "utf-8", ) -> None: ...
) -> None: ...
else:
def __init__(
self,
host: str = "",
user: str = "",
passwd: str = "",
acct: str = "",
timeout: float | None = ...,
source_address: tuple[str, int] | None = None,
) -> None: ...
def connect( def connect(
self, host: str = "", port: int = 0, timeout: float = -999, source_address: tuple[str, int] | None = None self, host: str = "", port: int = 0, timeout: float = -999, source_address: tuple[str, int] | None = None
) -> str: ... ) -> str: ...
@ -131,7 +119,7 @@ class FTP_TLS(FTP):
source_address: tuple[str, int] | None = None, source_address: tuple[str, int] | None = None,
encoding: str = "utf-8", encoding: str = "utf-8",
) -> None: ... ) -> None: ...
elif sys.version_info >= (3, 9): else:
def __init__( def __init__(
self, self,
host: str = "", host: str = "",
@ -146,19 +134,6 @@ class FTP_TLS(FTP):
*, *,
encoding: str = "utf-8", encoding: str = "utf-8",
) -> None: ... ) -> None: ...
else:
def __init__(
self,
host: str = "",
user: str = "",
passwd: str = "",
acct: str = "",
keyfile: str | None = None,
certfile: str | None = None,
context: SSLContext | None = None,
timeout: float | None = ...,
source_address: tuple[str, int] | None = None,
) -> None: ...
ssl_version: int ssl_version: int
keyfile: str | None keyfile: str | None
certfile: str | None certfile: str | None

View File

@ -2,12 +2,10 @@ import sys
import types import types
from _typeshed import SupportsAllComparisons, SupportsItems from _typeshed import SupportsAllComparisons, SupportsItems
from collections.abc import Callable, Hashable, Iterable, Sized from collections.abc import Callable, Hashable, Iterable, Sized
from types import GenericAlias
from typing import Any, Generic, Literal, NamedTuple, TypedDict, TypeVar, final, overload from typing import Any, Generic, Literal, NamedTuple, TypedDict, TypeVar, final, overload
from typing_extensions import ParamSpec, Self, TypeAlias from typing_extensions import ParamSpec, Self, TypeAlias
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [ __all__ = [
"update_wrapper", "update_wrapper",
"wraps", "wraps",
@ -22,11 +20,9 @@ __all__ = [
"singledispatch", "singledispatch",
"cached_property", "cached_property",
"singledispatchmethod", "singledispatchmethod",
"cache",
] ]
if sys.version_info >= (3, 9):
__all__ += ["cache"]
_T = TypeVar("_T") _T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True) _T_co = TypeVar("_T_co", covariant=True)
_S = TypeVar("_S") _S = TypeVar("_S")
@ -46,10 +42,9 @@ class _CacheInfo(NamedTuple):
maxsize: int | None maxsize: int | None
currsize: int currsize: int
if sys.version_info >= (3, 9): class _CacheParameters(TypedDict):
class _CacheParameters(TypedDict): maxsize: int
maxsize: int typed: bool
typed: bool
@final @final
class _lru_cache_wrapper(Generic[_T]): class _lru_cache_wrapper(Generic[_T]):
@ -57,9 +52,7 @@ class _lru_cache_wrapper(Generic[_T]):
def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T: ... def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T: ...
def cache_info(self) -> _CacheInfo: ... def cache_info(self) -> _CacheInfo: ...
def cache_clear(self) -> None: ... def cache_clear(self) -> None: ...
if sys.version_info >= (3, 9): def cache_parameters(self) -> _CacheParameters: ...
def cache_parameters(self) -> _CacheParameters: ...
def __copy__(self) -> _lru_cache_wrapper[_T]: ... def __copy__(self) -> _lru_cache_wrapper[_T]: ...
def __deepcopy__(self, memo: Any, /) -> _lru_cache_wrapper[_T]: ... def __deepcopy__(self, memo: Any, /) -> _lru_cache_wrapper[_T]: ...
@ -131,8 +124,7 @@ class partial(Generic[_T]):
def keywords(self) -> dict[str, Any]: ... def keywords(self) -> dict[str, Any]: ...
def __new__(cls, func: Callable[..., _T], /, *args: Any, **kwargs: Any) -> Self: ... def __new__(cls, func: Callable[..., _T], /, *args: Any, **kwargs: Any) -> Self: ...
def __call__(self, /, *args: Any, **kwargs: Any) -> _T: ... def __call__(self, /, *args: Any, **kwargs: Any) -> _T: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
# With protocols, this could change into a generic protocol that defines __get__ and returns _T # With protocols, this could change into a generic protocol that defines __get__ and returns _T
_Descriptor: TypeAlias = Any _Descriptor: TypeAlias = Any
@ -148,8 +140,7 @@ class partialmethod(Generic[_T]):
def __get__(self, obj: Any, cls: type[Any] | None = None) -> Callable[..., _T]: ... def __get__(self, obj: Any, cls: type[Any] | None = None) -> Callable[..., _T]: ...
@property @property
def __isabstractmethod__(self) -> bool: ... def __isabstractmethod__(self) -> bool: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
_RegType: TypeAlias = type[Any] | types.UnionType _RegType: TypeAlias = type[Any] | types.UnionType
@ -200,12 +191,9 @@ class cached_property(Generic[_T_co]):
def __set_name__(self, owner: type[Any], name: str) -> None: ... def __set_name__(self, owner: type[Any], name: str) -> None: ...
# __set__ is not defined at runtime, but @cached_property is designed to be settable # __set__ is not defined at runtime, but @cached_property is designed to be settable
def __set__(self, instance: object, value: _T_co) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues] def __set__(self, instance: object, value: _T_co) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 9):
def cache(user_function: Callable[..., _T], /) -> _lru_cache_wrapper[_T]: ...
def cache(user_function: Callable[..., _T], /) -> _lru_cache_wrapper[_T]: ...
def _make_key( def _make_key(
args: tuple[Hashable, ...], args: tuple[Hashable, ...],
kwds: SupportsItems[Any, Any], kwds: SupportsItems[Any, Any],

View File

@ -1,4 +1,3 @@
import sys
from collections.abc import Callable from collections.abc import Callable
from typing import Any, Final, Literal from typing import Any, Final, Literal
from typing_extensions import TypeAlias from typing_extensions import TypeAlias
@ -28,10 +27,7 @@ def get_referrers(*objs: Any) -> list[Any]: ...
def get_stats() -> list[dict[str, Any]]: ... def get_stats() -> list[dict[str, Any]]: ...
def get_threshold() -> tuple[int, int, int]: ... def get_threshold() -> tuple[int, int, int]: ...
def is_tracked(obj: Any, /) -> bool: ... def is_tracked(obj: Any, /) -> bool: ...
def is_finalized(obj: Any, /) -> bool: ...
if sys.version_info >= (3, 9):
def is_finalized(obj: Any, /) -> bool: ...
def isenabled() -> bool: ... def isenabled() -> bool: ...
def set_debug(flags: int, /) -> None: ... def set_debug(flags: int, /) -> None: ...
def set_threshold(threshold0: int, threshold1: int = ..., threshold2: int = ..., /) -> None: ... def set_threshold(threshold0: int, threshold1: int = ..., threshold2: int = ..., /) -> None: ...

View File

@ -5,16 +5,22 @@ from _hashlib import (
_HashObject, _HashObject,
openssl_md5 as md5, openssl_md5 as md5,
openssl_sha1 as sha1, openssl_sha1 as sha1,
openssl_sha3_224 as sha3_224,
openssl_sha3_256 as sha3_256,
openssl_sha3_384 as sha3_384,
openssl_sha3_512 as sha3_512,
openssl_sha224 as sha224, openssl_sha224 as sha224,
openssl_sha256 as sha256, openssl_sha256 as sha256,
openssl_sha384 as sha384, openssl_sha384 as sha384,
openssl_sha512 as sha512, openssl_sha512 as sha512,
openssl_shake_128 as shake_128,
openssl_shake_256 as shake_256,
pbkdf2_hmac as pbkdf2_hmac, pbkdf2_hmac as pbkdf2_hmac,
scrypt as scrypt, scrypt as scrypt,
) )
from _typeshed import ReadableBuffer from _typeshed import ReadableBuffer
from collections.abc import Callable, Set as AbstractSet from collections.abc import Callable, Set as AbstractSet
from typing import Protocol, type_check_only from typing import Protocol
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
__all__ = ( __all__ = (
@ -60,31 +66,7 @@ else:
"pbkdf2_hmac", "pbkdf2_hmac",
) )
if sys.version_info >= (3, 9): def new(name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = ...) -> HASH: ...
def new(name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = ...) -> HASH: ...
from _hashlib import (
openssl_sha3_224 as sha3_224,
openssl_sha3_256 as sha3_256,
openssl_sha3_384 as sha3_384,
openssl_sha3_512 as sha3_512,
openssl_shake_128 as shake_128,
openssl_shake_256 as shake_256,
)
else:
@type_check_only
class _VarLenHash(HASH):
def digest(self, length: int) -> bytes: ... # type: ignore[override]
def hexdigest(self, length: int) -> str: ... # type: ignore[override]
def new(name: str, data: ReadableBuffer = b"") -> HASH: ...
# At runtime these aren't functions but classes imported from _sha3
def sha3_224(string: ReadableBuffer = b"") -> HASH: ...
def sha3_256(string: ReadableBuffer = b"") -> HASH: ...
def sha3_384(string: ReadableBuffer = b"") -> HASH: ...
def sha3_512(string: ReadableBuffer = b"") -> HASH: ...
def shake_128(string: ReadableBuffer = b"") -> _VarLenHash: ...
def shake_256(string: ReadableBuffer = b"") -> _VarLenHash: ...
algorithms_guaranteed: AbstractSet[str] algorithms_guaranteed: AbstractSet[str]
algorithms_available: AbstractSet[str] algorithms_available: AbstractSet[str]

View File

@ -1,9 +1,8 @@
import sys from _hashlib import _HashObject, compare_digest as compare_digest
from _hashlib import _HashObject
from _typeshed import ReadableBuffer, SizedBuffer from _typeshed import ReadableBuffer, SizedBuffer
from collections.abc import Callable from collections.abc import Callable
from types import ModuleType from types import ModuleType
from typing import AnyStr, overload from typing import overload
from typing_extensions import TypeAlias from typing_extensions import TypeAlias
_DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType _DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType
@ -32,11 +31,3 @@ class HMAC:
def copy(self) -> HMAC: ... def copy(self) -> HMAC: ...
def digest(key: SizedBuffer, msg: ReadableBuffer, digest: _DigestMod) -> bytes: ... def digest(key: SizedBuffer, msg: ReadableBuffer, digest: _DigestMod) -> bytes: ...
if sys.version_info >= (3, 9):
from _hashlib import compare_digest as compare_digest
else:
@overload
def compare_digest(a: ReadableBuffer, b: ReadableBuffer, /) -> bool: ...
@overload
def compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...

View File

@ -19,8 +19,7 @@ class HTTPStatus(IntEnum):
CONTINUE = 100 CONTINUE = 100
SWITCHING_PROTOCOLS = 101 SWITCHING_PROTOCOLS = 101
PROCESSING = 102 PROCESSING = 102
if sys.version_info >= (3, 9): EARLY_HINTS = 103
EARLY_HINTS = 103
OK = 200 OK = 200
CREATED = 201 CREATED = 201
@ -66,16 +65,14 @@ class HTTPStatus(IntEnum):
RANGE_NOT_SATISFIABLE = 416 RANGE_NOT_SATISFIABLE = 416
REQUESTED_RANGE_NOT_SATISFIABLE = 416 REQUESTED_RANGE_NOT_SATISFIABLE = 416
EXPECTATION_FAILED = 417 EXPECTATION_FAILED = 417
if sys.version_info >= (3, 9): IM_A_TEAPOT = 418
IM_A_TEAPOT = 418
MISDIRECTED_REQUEST = 421 MISDIRECTED_REQUEST = 421
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
UNPROCESSABLE_CONTENT = 422 UNPROCESSABLE_CONTENT = 422
UNPROCESSABLE_ENTITY = 422 UNPROCESSABLE_ENTITY = 422
LOCKED = 423 LOCKED = 423
FAILED_DEPENDENCY = 424 FAILED_DEPENDENCY = 424
if sys.version_info >= (3, 9): TOO_EARLY = 425
TOO_EARLY = 425
UPGRADE_REQUIRED = 426 UPGRADE_REQUIRED = 426
PRECONDITION_REQUIRED = 428 PRECONDITION_REQUIRED = 428
TOO_MANY_REQUESTS = 429 TOO_MANY_REQUESTS = 429

View File

@ -44,8 +44,7 @@ HTTPS_PORT: int
CONTINUE: Literal[100] CONTINUE: Literal[100]
SWITCHING_PROTOCOLS: Literal[101] SWITCHING_PROTOCOLS: Literal[101]
PROCESSING: Literal[102] PROCESSING: Literal[102]
if sys.version_info >= (3, 9): EARLY_HINTS: Literal[103]
EARLY_HINTS: Literal[103]
OK: Literal[200] OK: Literal[200]
CREATED: Literal[201] CREATED: Literal[201]
@ -91,16 +90,14 @@ if sys.version_info >= (3, 13):
RANGE_NOT_SATISFIABLE: Literal[416] RANGE_NOT_SATISFIABLE: Literal[416]
REQUESTED_RANGE_NOT_SATISFIABLE: Literal[416] REQUESTED_RANGE_NOT_SATISFIABLE: Literal[416]
EXPECTATION_FAILED: Literal[417] EXPECTATION_FAILED: Literal[417]
if sys.version_info >= (3, 9): IM_A_TEAPOT: Literal[418]
IM_A_TEAPOT: Literal[418]
MISDIRECTED_REQUEST: Literal[421] MISDIRECTED_REQUEST: Literal[421]
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
UNPROCESSABLE_CONTENT: Literal[422] UNPROCESSABLE_CONTENT: Literal[422]
UNPROCESSABLE_ENTITY: Literal[422] UNPROCESSABLE_ENTITY: Literal[422]
LOCKED: Literal[423] LOCKED: Literal[423]
FAILED_DEPENDENCY: Literal[424] FAILED_DEPENDENCY: Literal[424]
if sys.version_info >= (3, 9): TOO_EARLY: Literal[425]
TOO_EARLY: Literal[425]
UPGRADE_REQUIRED: Literal[426] UPGRADE_REQUIRED: Literal[426]
PRECONDITION_REQUIRED: Literal[428] PRECONDITION_REQUIRED: Literal[428]
TOO_MANY_REQUESTS: Literal[429] TOO_MANY_REQUESTS: Literal[429]

View File

@ -1,11 +1,8 @@
import sys
from collections.abc import Iterable, Mapping from collections.abc import Iterable, Mapping
from types import GenericAlias
from typing import Any, Generic, TypeVar, overload from typing import Any, Generic, TypeVar, overload
from typing_extensions import TypeAlias from typing_extensions import TypeAlias
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ["CookieError", "BaseCookie", "SimpleCookie"] __all__ = ["CookieError", "BaseCookie", "SimpleCookie"]
_DataType: TypeAlias = str | Mapping[str, str | Morsel[Any]] _DataType: TypeAlias = str | Mapping[str, str | Morsel[Any]]
@ -44,8 +41,7 @@ class Morsel(dict[str, Any], Generic[_T]):
def OutputString(self, attrs: list[str] | None = None) -> str: ... def OutputString(self, attrs: list[str] | None = None) -> str: ...
def __eq__(self, morsel: object) -> bool: ... def __eq__(self, morsel: object) -> bool: ...
def __setitem__(self, K: str, V: Any) -> None: ... def __setitem__(self, K: str, V: Any) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class BaseCookie(dict[str, Morsel[_T]], Generic[_T]): class BaseCookie(dict[str, Morsel[_T]], Generic[_T]):
def __init__(self, input: _DataType | None = None) -> None: ... def __init__(self, input: _DataType | None = None) -> None: ...

View File

@ -40,13 +40,8 @@ class IMAP4:
welcome: bytes welcome: bytes
capabilities: tuple[str, ...] capabilities: tuple[str, ...]
PROTOCOL_VERSION: str PROTOCOL_VERSION: str
if sys.version_info >= (3, 9): def __init__(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ...
def __init__(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ... def open(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ...
def open(self, host: str = "", port: int = 143, timeout: float | None = None) -> None: ...
else:
def __init__(self, host: str = "", port: int = 143) -> None: ...
def open(self, host: str = "", port: int = 143) -> None: ...
def __getattr__(self, attr: str) -> Any: ... def __getattr__(self, attr: str) -> Any: ...
host: str host: str
port: int port: int
@ -101,9 +96,7 @@ class IMAP4:
def thread(self, threading_algorithm: str, charset: str, *search_criteria: str) -> _CommandResults: ... def thread(self, threading_algorithm: str, charset: str, *search_criteria: str) -> _CommandResults: ...
def uid(self, command: str, *args: str) -> _CommandResults: ... def uid(self, command: str, *args: str) -> _CommandResults: ...
def unsubscribe(self, mailbox: str) -> _CommandResults: ... def unsubscribe(self, mailbox: str) -> _CommandResults: ...
if sys.version_info >= (3, 9): def unselect(self) -> _CommandResults: ...
def unselect(self) -> _CommandResults: ...
def xatom(self, name: str, *args: str) -> _CommandResults: ... def xatom(self, name: str, *args: str) -> _CommandResults: ...
def print_log(self) -> None: ... def print_log(self) -> None: ...
@ -115,7 +108,7 @@ class IMAP4_SSL(IMAP4):
def __init__( def __init__(
self, host: str = "", port: int = 993, *, ssl_context: SSLContext | None = None, timeout: float | None = None self, host: str = "", port: int = 993, *, ssl_context: SSLContext | None = None, timeout: float | None = None
) -> None: ... ) -> None: ...
elif sys.version_info >= (3, 9): else:
def __init__( def __init__(
self, self,
host: str = "", host: str = "",
@ -125,22 +118,9 @@ class IMAP4_SSL(IMAP4):
ssl_context: SSLContext | None = None, ssl_context: SSLContext | None = None,
timeout: float | None = None, timeout: float | None = None,
) -> None: ... ) -> None: ...
else:
def __init__(
self,
host: str = "",
port: int = 993,
keyfile: str | None = None,
certfile: str | None = None,
ssl_context: SSLContext | None = None,
) -> None: ...
sslobj: SSLSocket sslobj: SSLSocket
file: IO[Any] file: IO[Any]
if sys.version_info >= (3, 9): def open(self, host: str = "", port: int | None = 993, timeout: float | None = None) -> None: ...
def open(self, host: str = "", port: int | None = 993, timeout: float | None = None) -> None: ...
else:
def open(self, host: str = "", port: int | None = 993) -> None: ...
def ssl(self) -> SSLSocket: ... def ssl(self) -> SSLSocket: ...
class IMAP4_stream(IMAP4): class IMAP4_stream(IMAP4):
@ -150,10 +130,7 @@ class IMAP4_stream(IMAP4):
process: subprocess.Popen[bytes] process: subprocess.Popen[bytes]
writefile: IO[Any] writefile: IO[Any]
readfile: IO[Any] readfile: IO[Any]
if sys.version_info >= (3, 9): def open(self, host: str | None = None, port: int | None = None, timeout: float | None = None) -> None: ...
def open(self, host: str | None = None, port: int | None = None, timeout: float | None = None) -> None: ...
else:
def open(self, host: str | None = None, port: int | None = None) -> None: ...
class _Authenticator: class _Authenticator:
mech: Callable[[bytes], bytes | bytearray | memoryview | str | None] mech: Callable[[bytes], bytes | bytearray | memoryview | str | None]

View File

@ -125,49 +125,48 @@ class ResourceReader(metaclass=ABCMeta):
@abstractmethod @abstractmethod
def contents(self) -> Iterator[str]: ... def contents(self) -> Iterator[str]: ...
if sys.version_info >= (3, 9): @runtime_checkable
@runtime_checkable class Traversable(Protocol):
class Traversable(Protocol): @abstractmethod
def is_dir(self) -> bool: ...
@abstractmethod
def is_file(self) -> bool: ...
@abstractmethod
def iterdir(self) -> Iterator[Traversable]: ...
if sys.version_info >= (3, 11):
@abstractmethod @abstractmethod
def is_dir(self) -> bool: ... def joinpath(self, *descendants: str) -> Traversable: ...
else:
@abstractmethod @abstractmethod
def is_file(self) -> bool: ... def joinpath(self, child: str, /) -> Traversable: ...
@abstractmethod
def iterdir(self) -> Iterator[Traversable]: ...
if sys.version_info >= (3, 11):
@abstractmethod
def joinpath(self, *descendants: str) -> Traversable: ...
else:
@abstractmethod
def joinpath(self, child: str, /) -> Traversable: ...
# The documentation and runtime protocol allows *args, **kwargs arguments, # The documentation and runtime protocol allows *args, **kwargs arguments,
# but this would mean that all implementers would have to support them, # but this would mean that all implementers would have to support them,
# which is not the case. # which is not the case.
@overload @overload
@abstractmethod
def open(self, mode: Literal["r"] = "r", *, encoding: str | None = None, errors: str | None = None) -> IO[str]: ...
@overload
@abstractmethod
def open(self, mode: Literal["rb"]) -> IO[bytes]: ...
@property
@abstractmethod
def name(self) -> str: ...
if sys.version_info >= (3, 10):
def __truediv__(self, child: str, /) -> Traversable: ...
else:
@abstractmethod @abstractmethod
def open(self, mode: Literal["r"] = "r", *, encoding: str | None = None, errors: str | None = None) -> IO[str]: ... def __truediv__(self, child: str, /) -> Traversable: ...
@overload
@abstractmethod
def open(self, mode: Literal["rb"]) -> IO[bytes]: ...
@property
@abstractmethod
def name(self) -> str: ...
if sys.version_info >= (3, 10):
def __truediv__(self, child: str, /) -> Traversable: ...
else:
@abstractmethod
def __truediv__(self, child: str, /) -> Traversable: ...
@abstractmethod @abstractmethod
def read_bytes(self) -> bytes: ... def read_bytes(self) -> bytes: ...
@abstractmethod @abstractmethod
def read_text(self, encoding: str | None = None) -> str: ... def read_text(self, encoding: str | None = None) -> str: ...
class TraversableResources(ResourceReader): class TraversableResources(ResourceReader):
@abstractmethod @abstractmethod
def files(self) -> Traversable: ... def files(self) -> Traversable: ...
def open_resource(self, resource: str) -> BufferedReader: ... def open_resource(self, resource: str) -> BufferedReader: ...
def resource_path(self, resource: Any) -> str: ... def resource_path(self, resource: Any) -> str: ...
def is_resource(self, path: str) -> bool: ... def is_resource(self, path: str) -> bool: ...
def contents(self) -> Iterator[str]: ... def contents(self) -> Iterator[str]: ...

View File

@ -71,11 +71,10 @@ class EntryPoint(_EntryPointBase):
def load(self) -> Any: ... # Callable[[], Any] or an importable module def load(self) -> Any: ... # Callable[[], Any] or an importable module
@property @property
def extras(self) -> list[str]: ... def extras(self) -> list[str]: ...
if sys.version_info >= (3, 9): @property
@property def module(self) -> str: ...
def module(self) -> str: ... @property
@property def attr(self) -> str: ...
def attr(self) -> str: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
dist: ClassVar[Distribution | None] dist: ClassVar[Distribution | None]
def matches( def matches(

View File

@ -2,6 +2,7 @@ import os
import sys import sys
from collections.abc import Iterator from collections.abc import Iterator
from contextlib import AbstractContextManager from contextlib import AbstractContextManager
from importlib.abc import Traversable
from pathlib import Path from pathlib import Path
from types import ModuleType from types import ModuleType
from typing import Any, BinaryIO, Literal, TextIO from typing import Any, BinaryIO, Literal, TextIO
@ -12,13 +13,18 @@ if sys.version_info >= (3, 11):
else: else:
Package: TypeAlias = str | ModuleType Package: TypeAlias = str | ModuleType
if sys.version_info >= (3, 9): __all__ = [
from importlib.abc import Traversable "Package",
"as_file",
__all__ = ["Package", "contents", "is_resource", "open_binary", "open_text", "path", "read_binary", "read_text"] "contents",
"files",
if sys.version_info >= (3, 9): "is_resource",
__all__ += ["as_file", "files"] "open_binary",
"open_text",
"path",
"read_binary",
"read_text",
]
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__all__ += ["ResourceReader"] __all__ += ["ResourceReader"]
@ -31,11 +37,12 @@ if sys.version_info < (3, 11):
elif sys.version_info < (3, 13): elif sys.version_info < (3, 13):
Resource: TypeAlias = str Resource: TypeAlias = str
if sys.version_info >= (3, 13): if sys.version_info >= (3, 12):
from importlib.resources._common import Anchor as Anchor from importlib.resources._common import Anchor as Anchor
__all__ += ["Anchor"] __all__ += ["Anchor"]
if sys.version_info >= (3, 13):
from importlib.resources._functional import ( from importlib.resources._functional import (
contents as contents, contents as contents,
is_resource as is_resource, is_resource as is_resource,
@ -57,13 +64,12 @@ else:
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from importlib.resources._common import as_file as as_file from importlib.resources._common import as_file as as_file
elif sys.version_info >= (3, 9): else:
def as_file(path: Traversable) -> AbstractContextManager[Path, Literal[False]]: ... def as_file(path: Traversable) -> AbstractContextManager[Path, Literal[False]]: ...
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from importlib.resources._common import files as files from importlib.resources._common import files as files
else:
elif sys.version_info >= (3, 9):
def files(package: Package) -> Traversable: ... def files(package: Package) -> Traversable: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):

View File

@ -616,8 +616,7 @@ class Attribute(NamedTuple):
def classify_class_attrs(cls: type) -> list[Attribute]: ... def classify_class_attrs(cls: type) -> list[Attribute]: ...
if sys.version_info >= (3, 9): class ClassFoundException(Exception): ...
class ClassFoundException(Exception): ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
class BufferFlags(enum.IntFlag): class BufferFlags(enum.IntFlag):

View File

@ -36,9 +36,7 @@ class _BaseAddress(_IPAddressBase):
def __hash__(self) -> int: ... def __hash__(self) -> int: ...
def __int__(self) -> int: ... def __int__(self) -> int: ...
def __sub__(self, other: int) -> Self: ... def __sub__(self, other: int) -> Self: ...
if sys.version_info >= (3, 9): def __format__(self, fmt: str) -> str: ...
def __format__(self, fmt: str) -> str: ...
def __eq__(self, other: object) -> bool: ... def __eq__(self, other: object) -> bool: ...
def __lt__(self, other: Self) -> bool: ... def __lt__(self, other: Self) -> bool: ...
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
@ -184,10 +182,8 @@ class IPv6Address(_BaseV6, _BaseAddress):
def sixtofour(self) -> IPv4Address | None: ... def sixtofour(self) -> IPv4Address | None: ...
@property @property
def teredo(self) -> tuple[IPv4Address, IPv4Address] | None: ... def teredo(self) -> tuple[IPv4Address, IPv4Address] | None: ...
if sys.version_info >= (3, 9): @property
@property def scope_id(self) -> str | None: ...
def scope_id(self) -> str | None: ...
def __hash__(self) -> int: ... def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ... def __eq__(self, other: object) -> bool: ...

View File

@ -1,12 +1,10 @@
import sys import sys
from _typeshed import MaybeNone from _typeshed import MaybeNone
from collections.abc import Callable, Iterable, Iterator from collections.abc import Callable, Iterable, Iterator
from types import GenericAlias
from typing import Any, Generic, Literal, SupportsComplex, SupportsFloat, SupportsIndex, SupportsInt, TypeVar, overload from typing import Any, Generic, Literal, SupportsComplex, SupportsFloat, SupportsIndex, SupportsInt, TypeVar, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T") _T = TypeVar("_T")
_S = TypeVar("_S") _S = TypeVar("_S")
_N = TypeVar("_N", int, float, SupportsFloat, SupportsInt, SupportsIndex, SupportsComplex) _N = TypeVar("_N", int, float, SupportsFloat, SupportsInt, SupportsIndex, SupportsComplex)
@ -68,8 +66,7 @@ class chain(Generic[_T]):
@classmethod @classmethod
# We use type[Any] and not type[_S] to not lose the type inference from __iterable # We use type[Any] and not type[_S] to not lose the type inference from __iterable
def from_iterable(cls: type[Any], iterable: Iterable[Iterable[_S]], /) -> chain[_S]: ... def from_iterable(cls: type[Any], iterable: Iterable[Iterable[_S]], /) -> chain[_S]: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class compress(Generic[_T]): class compress(Generic[_T]):
def __new__(cls, data: Iterable[_T], selectors: Iterable[Any]) -> Self: ... def __new__(cls, data: Iterable[_T], selectors: Iterable[Any]) -> Self: ...

View File

@ -1,11 +1,7 @@
import sys
from collections.abc import Sequence from collections.abc import Sequence
from typing import Final from typing import Final
if sys.version_info >= (3, 9): __all__ = ["iskeyword", "issoftkeyword", "kwlist", "softkwlist"]
__all__ = ["iskeyword", "issoftkeyword", "kwlist", "softkwlist"]
else:
__all__ = ["iskeyword", "kwlist"]
def iskeyword(s: str, /) -> bool: ... def iskeyword(s: str, /) -> bool: ...
@ -13,9 +9,8 @@ def iskeyword(s: str, /) -> bool: ...
# type it as a sequence # type it as a sequence
kwlist: Final[Sequence[str]] kwlist: Final[Sequence[str]]
if sys.version_info >= (3, 9): def issoftkeyword(s: str, /) -> bool: ...
def issoftkeyword(s: str, /) -> bool: ...
# a list at runtime, but you're not meant to mutate it; # a list at runtime, but you're not meant to mutate it;
# type it as a sequence # type it as a sequence
softkwlist: Final[Sequence[str]] softkwlist: Final[Sequence[str]]

View File

@ -1,12 +1,8 @@
import sys
from collections.abc import Callable from collections.abc import Callable
from typing import Any from typing import Any
from typing_extensions import TypeAlias from typing_extensions import TypeAlias
if sys.version_info >= (3, 9): __all__ = ["getline", "clearcache", "checkcache", "lazycache"]
__all__ = ["getline", "clearcache", "checkcache", "lazycache"]
else:
__all__ = ["getline", "clearcache", "checkcache"]
_ModuleGlobals: TypeAlias = dict[str, Any] _ModuleGlobals: TypeAlias = dict[str, Any]
_ModuleMetadata: TypeAlias = tuple[int, float | None, list[str], str] _ModuleMetadata: TypeAlias = tuple[int, float | None, list[str], str]

View File

@ -6,13 +6,10 @@ from io import TextIOWrapper
from re import Pattern from re import Pattern
from string import Template from string import Template
from time import struct_time from time import struct_time
from types import FrameType, TracebackType from types import FrameType, GenericAlias, TracebackType
from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload from typing import Any, ClassVar, Final, Generic, Literal, Protocol, TextIO, TypeVar, overload
from typing_extensions import Self, TypeAlias, deprecated from typing_extensions import Self, TypeAlias, deprecated
if sys.version_info >= (3, 11):
from types import GenericAlias
__all__ = [ __all__ = [
"BASIC_FORMAT", "BASIC_FORMAT",
"BufferingFormatter", "BufferingFormatter",
@ -273,10 +270,7 @@ class Formatter:
datefmt: str | None # undocumented datefmt: str | None # undocumented
_style: PercentStyle # undocumented _style: PercentStyle # undocumented
default_time_format: str default_time_format: str
if sys.version_info >= (3, 9): default_msec_format: str | None
default_msec_format: str | None
else:
default_msec_format: str
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
def __init__( def __init__(
@ -577,37 +571,20 @@ if sys.version_info >= (3, 11):
def getLevelNamesMapping() -> dict[str, int]: ... def getLevelNamesMapping() -> dict[str, int]: ...
def makeLogRecord(dict: Mapping[str, object]) -> LogRecord: ... def makeLogRecord(dict: Mapping[str, object]) -> LogRecord: ...
def basicConfig(
if sys.version_info >= (3, 9): *,
def basicConfig( filename: StrPath | None = ...,
*, filemode: str = ...,
filename: StrPath | None = ..., format: str = ...,
filemode: str = ..., datefmt: str | None = ...,
format: str = ..., style: _FormatStyle = ...,
datefmt: str | None = ..., level: _Level | None = ...,
style: _FormatStyle = ..., stream: SupportsWrite[str] | None = ...,
level: _Level | None = ..., handlers: Iterable[Handler] | None = ...,
stream: SupportsWrite[str] | None = ..., force: bool | None = ...,
handlers: Iterable[Handler] | None = ..., encoding: str | None = ...,
force: bool | None = ..., errors: str | None = ...,
encoding: str | None = ..., ) -> None: ...
errors: str | None = ...,
) -> None: ...
else:
def basicConfig(
*,
filename: StrPath | None = ...,
filemode: str = ...,
format: str = ...,
datefmt: str | None = ...,
style: _FormatStyle = ...,
level: _Level | None = ...,
stream: SupportsWrite[str] | None = ...,
handlers: Iterable[Handler] | None = ...,
force: bool = ...,
) -> None: ...
def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is undocumented def shutdown(handlerList: Sequence[Any] = ...) -> None: ... # handlerList is undocumented
def setLoggerClass(klass: type[Logger]) -> None: ... def setLoggerClass(klass: type[Logger]) -> None: ...
def captureWarnings(capture: bool) -> None: ... def captureWarnings(capture: bool) -> None: ...
@ -633,14 +610,10 @@ class FileHandler(StreamHandler[TextIOWrapper]):
mode: str # undocumented mode: str # undocumented
encoding: str | None # undocumented encoding: str | None # undocumented
delay: bool # undocumented delay: bool # undocumented
if sys.version_info >= (3, 9): errors: str | None # undocumented
errors: str | None # undocumented def __init__(
def __init__( self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False, errors: str | None = None
self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False, errors: str | None = None ) -> None: ...
) -> None: ...
else:
def __init__(self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False) -> None: ...
def _open(self) -> TextIOWrapper: ... # undocumented def _open(self) -> TextIOWrapper: ... # undocumented
class NullHandler(Handler): ... class NullHandler(Handler): ...

View File

@ -22,54 +22,34 @@ SYSLOG_TCP_PORT: Final[int]
class WatchedFileHandler(FileHandler): class WatchedFileHandler(FileHandler):
dev: int # undocumented dev: int # undocumented
ino: int # undocumented ino: int # undocumented
if sys.version_info >= (3, 9): def __init__(
def __init__( self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False, errors: str | None = None
self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False, errors: str | None = None ) -> None: ...
) -> None: ...
else:
def __init__(self, filename: StrPath, mode: str = "a", encoding: str | None = None, delay: bool = False) -> None: ...
def _statstream(self) -> None: ... # undocumented def _statstream(self) -> None: ... # undocumented
def reopenIfNeeded(self) -> None: ... def reopenIfNeeded(self) -> None: ...
class BaseRotatingHandler(FileHandler): class BaseRotatingHandler(FileHandler):
namer: Callable[[str], str] | None namer: Callable[[str], str] | None
rotator: Callable[[str, str], None] | None rotator: Callable[[str, str], None] | None
if sys.version_info >= (3, 9): def __init__(
def __init__( self, filename: StrPath, mode: str, encoding: str | None = None, delay: bool = False, errors: str | None = None
self, filename: StrPath, mode: str, encoding: str | None = None, delay: bool = False, errors: str | None = None ) -> None: ...
) -> None: ...
else:
def __init__(self, filename: StrPath, mode: str, encoding: str | None = None, delay: bool = False) -> None: ...
def rotation_filename(self, default_name: str) -> str: ... def rotation_filename(self, default_name: str) -> str: ...
def rotate(self, source: str, dest: str) -> None: ... def rotate(self, source: str, dest: str) -> None: ...
class RotatingFileHandler(BaseRotatingHandler): class RotatingFileHandler(BaseRotatingHandler):
maxBytes: int # undocumented maxBytes: int # undocumented
backupCount: int # undocumented backupCount: int # undocumented
if sys.version_info >= (3, 9): def __init__(
def __init__( self,
self, filename: StrPath,
filename: StrPath, mode: str = "a",
mode: str = "a", maxBytes: int = 0,
maxBytes: int = 0, backupCount: int = 0,
backupCount: int = 0, encoding: str | None = None,
encoding: str | None = None, delay: bool = False,
delay: bool = False, errors: str | None = None,
errors: str | None = None, ) -> None: ...
) -> None: ...
else:
def __init__(
self,
filename: StrPath,
mode: str = "a",
maxBytes: int = 0,
backupCount: int = 0,
encoding: str | None = None,
delay: bool = False,
) -> None: ...
def doRollover(self) -> None: ... def doRollover(self) -> None: ...
def shouldRollover(self, record: LogRecord) -> int: ... # undocumented def shouldRollover(self, record: LogRecord) -> int: ... # undocumented
@ -83,32 +63,18 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
dayOfWeek: int # undocumented dayOfWeek: int # undocumented
rolloverAt: int # undocumented rolloverAt: int # undocumented
extMatch: Pattern[str] # undocumented extMatch: Pattern[str] # undocumented
if sys.version_info >= (3, 9): def __init__(
def __init__( self,
self, filename: StrPath,
filename: StrPath, when: str = "h",
when: str = "h", interval: int = 1,
interval: int = 1, backupCount: int = 0,
backupCount: int = 0, encoding: str | None = None,
encoding: str | None = None, delay: bool = False,
delay: bool = False, utc: bool = False,
utc: bool = False, atTime: datetime.time | None = None,
atTime: datetime.time | None = None, errors: str | None = None,
errors: str | None = None, ) -> None: ...
) -> None: ...
else:
def __init__(
self,
filename: StrPath,
when: str = "h",
interval: int = 1,
backupCount: int = 0,
encoding: str | None = None,
delay: bool = False,
utc: bool = False,
atTime: datetime.time | None = None,
) -> None: ...
def doRollover(self) -> None: ... def doRollover(self) -> None: ...
def shouldRollover(self, record: LogRecord) -> int: ... # undocumented def shouldRollover(self, record: LogRecord) -> int: ... # undocumented
def computeRollover(self, currentTime: int) -> int: ... # undocumented def computeRollover(self, currentTime: int) -> int: ... # undocumented
@ -155,13 +121,10 @@ class SysLogHandler(Handler):
LOG_CRON: int LOG_CRON: int
LOG_AUTHPRIV: int LOG_AUTHPRIV: int
LOG_FTP: int LOG_FTP: int
LOG_NTP: int
if sys.version_info >= (3, 9): LOG_SECURITY: int
LOG_NTP: int LOG_CONSOLE: int
LOG_SECURITY: int LOG_SOLCRON: int
LOG_CONSOLE: int
LOG_SOLCRON: int
LOG_LOCAL0: int LOG_LOCAL0: int
LOG_LOCAL1: int LOG_LOCAL1: int
LOG_LOCAL2: int LOG_LOCAL2: int
@ -191,7 +154,7 @@ class SysLogHandler(Handler):
class NTEventLogHandler(Handler): class NTEventLogHandler(Handler):
def __init__(self, appname: str, dllname: str | None = None, logtype: str = "Application") -> None: ... def __init__(self, appname: str, dllname: str | None = None, logtype: str = "Application") -> None: ...
def getEventCategory(self, record: LogRecord) -> int: ... def getEventCategory(self, record: LogRecord) -> int: ...
# TODO correct return value? # TODO: correct return value?
def getEventType(self, record: LogRecord) -> int: ... def getEventType(self, record: LogRecord) -> int: ...
def getMessageID(self, record: LogRecord) -> int: ... def getMessageID(self, record: LogRecord) -> int: ...
@ -248,8 +211,7 @@ class HTTPHandler(Handler):
context: ssl.SSLContext | None = None, context: ssl.SSLContext | None = None,
) -> None: ... ) -> None: ...
def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ... def mapLogRecord(self, record: LogRecord) -> dict[str, Any]: ...
if sys.version_info >= (3, 9): def getConnection(self, host: str, secure: bool) -> http.client.HTTPConnection: ... # undocumented
def getConnection(self, host: str, secure: bool) -> http.client.HTTPConnection: ... # undocumented
class _QueueLike(Protocol[_T]): class _QueueLike(Protocol[_T]):
def get(self) -> _T: ... def get(self) -> _T: ...

View File

@ -4,13 +4,10 @@ import sys
from _typeshed import StrPath, SupportsNoArgReadline, SupportsRead from _typeshed import StrPath, SupportsNoArgReadline, SupportsRead
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from types import TracebackType from types import GenericAlias, TracebackType
from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload from typing import IO, Any, AnyStr, Generic, Literal, Protocol, TypeVar, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [ __all__ = [
"Mailbox", "Mailbox",
"Maildir", "Maildir",
@ -101,8 +98,7 @@ class Mailbox(Generic[_MessageT]):
def unlock(self) -> None: ... def unlock(self) -> None: ...
@abstractmethod @abstractmethod
def close(self) -> None: ... def close(self) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class Maildir(Mailbox[MaildirMessage]): class Maildir(Mailbox[MaildirMessage]):
colon: str colon: str
@ -251,8 +247,7 @@ class _ProxyFile(Generic[AnyStr]):
def flush(self) -> None: ... def flush(self) -> None: ...
@property @property
def closed(self) -> bool: ... def closed(self) -> bool: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class _PartialFile(_ProxyFile[AnyStr]): class _PartialFile(_ProxyFile[AnyStr]):
def __init__(self, f: IO[AnyStr], start: int | None = None, stop: int | None = None) -> None: ... def __init__(self, f: IO[AnyStr], start: int | None = None, stop: int | None = None) -> None: ...

View File

@ -61,13 +61,7 @@ def fmod(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float: ...
def frexp(x: _SupportsFloatOrIndex, /) -> tuple[float, int]: ... def frexp(x: _SupportsFloatOrIndex, /) -> tuple[float, int]: ...
def fsum(seq: Iterable[_SupportsFloatOrIndex], /) -> float: ... def fsum(seq: Iterable[_SupportsFloatOrIndex], /) -> float: ...
def gamma(x: _SupportsFloatOrIndex, /) -> float: ... def gamma(x: _SupportsFloatOrIndex, /) -> float: ...
def gcd(*integers: SupportsIndex) -> int: ...
if sys.version_info >= (3, 9):
def gcd(*integers: SupportsIndex) -> int: ...
else:
def gcd(x: SupportsIndex, y: SupportsIndex, /) -> int: ...
def hypot(*coordinates: _SupportsFloatOrIndex) -> float: ... def hypot(*coordinates: _SupportsFloatOrIndex) -> float: ...
def isclose( def isclose(
a: _SupportsFloatOrIndex, a: _SupportsFloatOrIndex,
@ -80,10 +74,7 @@ def isinf(x: _SupportsFloatOrIndex, /) -> bool: ...
def isfinite(x: _SupportsFloatOrIndex, /) -> bool: ... def isfinite(x: _SupportsFloatOrIndex, /) -> bool: ...
def isnan(x: _SupportsFloatOrIndex, /) -> bool: ... def isnan(x: _SupportsFloatOrIndex, /) -> bool: ...
def isqrt(n: SupportsIndex, /) -> int: ... def isqrt(n: SupportsIndex, /) -> int: ...
def lcm(*integers: SupportsIndex) -> int: ...
if sys.version_info >= (3, 9):
def lcm(*integers: SupportsIndex) -> int: ...
def ldexp(x: _SupportsFloatOrIndex, i: int, /) -> float: ... def ldexp(x: _SupportsFloatOrIndex, i: int, /) -> float: ...
def lgamma(x: _SupportsFloatOrIndex, /) -> float: ... def lgamma(x: _SupportsFloatOrIndex, /) -> float: ...
def log(x: _SupportsFloatOrIndex, base: _SupportsFloatOrIndex = ...) -> float: ... def log(x: _SupportsFloatOrIndex, base: _SupportsFloatOrIndex = ...) -> float: ...
@ -95,7 +86,7 @@ def modf(x: _SupportsFloatOrIndex, /) -> tuple[float, float]: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /, *, steps: SupportsIndex | None = None) -> float: ... def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /, *, steps: SupportsIndex | None = None) -> float: ...
elif sys.version_info >= (3, 9): else:
def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float: ... def nextafter(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float: ...
def perm(n: SupportsIndex, k: SupportsIndex | None = None, /) -> int: ... def perm(n: SupportsIndex, k: SupportsIndex | None = None, /) -> int: ...
@ -140,9 +131,7 @@ class _SupportsTrunc(Protocol[_T_co]):
def __trunc__(self) -> _T_co: ... def __trunc__(self) -> _T_co: ...
def trunc(x: _SupportsTrunc[_T], /) -> _T: ... def trunc(x: _SupportsTrunc[_T], /) -> _T: ...
def ulp(x: _SupportsFloatOrIndex, /) -> float: ...
if sys.version_info >= (3, 9):
def ulp(x: _SupportsFloatOrIndex, /) -> float: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def fma(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, z: _SupportsFloatOrIndex, /) -> float: ... def fma(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, z: _SupportsFloatOrIndex, /) -> float: ...

View File

@ -3,7 +3,7 @@ import sys
import threading import threading
from _typeshed import SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT from _typeshed import SupportsKeysAndGetItem, SupportsRichComparison, SupportsRichComparisonT
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, MutableSequence, Sequence from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, MutableSequence, Sequence
from types import TracebackType from types import GenericAlias, TracebackType
from typing import Any, AnyStr, ClassVar, Generic, SupportsIndex, TypeVar, overload from typing import Any, AnyStr, ClassVar, Generic, SupportsIndex, TypeVar, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
@ -15,9 +15,6 @@ from .util import Finalize as _Finalize
__all__ = ["BaseManager", "SyncManager", "BaseProxy", "Token", "SharedMemoryManager"] __all__ = ["BaseManager", "SyncManager", "BaseProxy", "Token", "SharedMemoryManager"]
if sys.version_info >= (3, 9):
from types import GenericAlias
_T = TypeVar("_T") _T = TypeVar("_T")
_KT = TypeVar("_KT") _KT = TypeVar("_KT")
_VT = TypeVar("_VT") _VT = TypeVar("_VT")
@ -59,8 +56,7 @@ class ValueProxy(BaseProxy, Generic[_T]):
def get(self) -> _T: ... def get(self) -> _T: ...
def set(self, value: _T) -> None: ... def set(self, value: _T) -> None: ...
value: _T value: _T
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
class _BaseDictProxy(BaseProxy, MutableMapping[_KT, _VT]): class _BaseDictProxy(BaseProxy, MutableMapping[_KT, _VT]):

View File

@ -1,13 +1,9 @@
import sys
from collections.abc import Callable, Iterable, Mapping from collections.abc import Callable, Iterable, Mapping
from multiprocessing.context import DefaultContext, Process from multiprocessing.context import DefaultContext, Process
from types import TracebackType from types import GenericAlias, TracebackType
from typing import Any, Final, Generic, TypeVar from typing import Any, Final, Generic, TypeVar
from typing_extensions import Self from typing_extensions import Self
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ["Pool", "ThreadPool"] __all__ = ["Pool", "ThreadPool"]
_S = TypeVar("_S") _S = TypeVar("_S")
@ -21,8 +17,7 @@ class ApplyResult(Generic[_T]):
def wait(self, timeout: float | None = None) -> None: ... def wait(self, timeout: float | None = None) -> None: ...
def ready(self) -> bool: ... def ready(self) -> bool: ...
def successful(self) -> bool: ... def successful(self) -> bool: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
# alias created during issue #17805 # alias created during issue #17805
AsyncResult = ApplyResult AsyncResult = ApplyResult

View File

@ -1,9 +1,7 @@
import sys import sys
from types import GenericAlias
from typing import Any, Generic, TypeVar from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ["Queue", "SimpleQueue", "JoinableQueue"] __all__ = ["Queue", "SimpleQueue", "JoinableQueue"]
_T = TypeVar("_T") _T = TypeVar("_T")
@ -31,11 +29,8 @@ class JoinableQueue(Queue[_T]):
class SimpleQueue(Generic[_T]): class SimpleQueue(Generic[_T]):
def __init__(self, *, ctx: Any = ...) -> None: ... def __init__(self, *, ctx: Any = ...) -> None: ...
if sys.version_info >= (3, 9): def close(self) -> None: ...
def close(self) -> None: ...
def empty(self) -> bool: ... def empty(self) -> bool: ...
def get(self) -> _T: ... def get(self) -> _T: ...
def put(self, obj: _T) -> None: ... def put(self, obj: _T) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

View File

@ -1,3 +1,4 @@
import sys
from _typeshed import FileDescriptorOrPath from _typeshed import FileDescriptorOrPath
from collections.abc import Sized from collections.abc import Sized
@ -8,6 +9,8 @@ class ResourceTracker:
def ensure_running(self) -> None: ... def ensure_running(self) -> None: ...
def register(self, name: Sized, rtype: str) -> None: ... def register(self, name: Sized, rtype: str) -> None: ...
def unregister(self, name: Sized, rtype: str) -> None: ... def unregister(self, name: Sized, rtype: str) -> None: ...
if sys.version_info >= (3, 12):
def __del__(self) -> None: ...
_resource_tracker: ResourceTracker _resource_tracker: ResourceTracker
ensure_running = _resource_tracker.ensure_running ensure_running = _resource_tracker.ensure_running

View File

@ -1,11 +1,9 @@
import sys import sys
from collections.abc import Iterable from collections.abc import Iterable
from types import GenericAlias
from typing import Any, Generic, TypeVar, overload from typing import Any, Generic, TypeVar, overload
from typing_extensions import Self from typing_extensions import Self
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ["SharedMemory", "ShareableList"] __all__ = ["SharedMemory", "ShareableList"]
_SLT = TypeVar("_SLT", int, float, bool, str, bytes, None) _SLT = TypeVar("_SLT", int, float, bool, str, bytes, None)
@ -40,5 +38,4 @@ class ShareableList(Generic[_SLT]):
def format(self) -> str: ... def format(self) -> str: ...
def count(self, value: _SLT) -> int: ... def count(self, value: _SLT) -> int: ...
def index(self, value: _SLT) -> int: ... def index(self, value: _SLT) -> int: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...

View File

@ -1,7 +1,6 @@
import datetime import datetime
import socket import socket
import ssl import ssl
import sys
from _typeshed import Unused from _typeshed import Unused
from builtins import list as _list # conflicts with a method named "list" from builtins import list as _list # conflicts with a method named "list"
from collections.abc import Iterable from collections.abc import Iterable
@ -98,10 +97,6 @@ class NNTP:
def over( def over(
self, message_spec: None | str | _list[Any] | tuple[Any, ...], *, file: _File = None self, message_spec: None | str | _list[Any] | tuple[Any, ...], *, file: _File = None
) -> tuple[str, _list[tuple[int, dict[str, str]]]]: ... ) -> tuple[str, _list[tuple[int, dict[str, str]]]]: ...
if sys.version_info < (3, 9):
def xgtitle(self, group: str, *, file: _File = None) -> tuple[str, _list[tuple[str, str]]]: ...
def xpath(self, id: Any) -> tuple[str, str]: ...
def date(self) -> tuple[str, datetime.datetime]: ... def date(self) -> tuple[str, datetime.datetime]: ...
def post(self, data: bytes | Iterable[bytes]) -> str: ... def post(self, data: bytes | Iterable[bytes]) -> str: ...
def ihave(self, message_id: Any, data: bytes | Iterable[bytes]) -> str: ... def ihave(self, message_id: Any, data: bytes | Iterable[bytes]) -> str: ...

View File

@ -89,14 +89,14 @@ if sys.platform == "win32":
umask as umask, umask as umask,
uname_result as uname_result, uname_result as uname_result,
unlink as unlink, unlink as unlink,
unsetenv as unsetenv,
urandom as urandom, urandom as urandom,
utime as utime, utime as utime,
waitpid as waitpid, waitpid as waitpid,
waitstatus_to_exitcode as waitstatus_to_exitcode,
write as write, write as write,
) )
if sys.version_info >= (3, 9):
from os import unsetenv as unsetenv, waitstatus_to_exitcode as waitstatus_to_exitcode
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from os import EX_OK as EX_OK from os import EX_OK as EX_OK
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):

View File

@ -23,23 +23,7 @@ else:
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
__all__ += ["hasjump"] __all__ += ["hasjump"]
if sys.version_info >= (3, 9): cmp_op: tuple[Literal["<"], Literal["<="], Literal["=="], Literal["!="], Literal[">"], Literal[">="]]
cmp_op: tuple[Literal["<"], Literal["<="], Literal["=="], Literal["!="], Literal[">"], Literal[">="]]
else:
cmp_op: tuple[
Literal["<"],
Literal["<="],
Literal["=="],
Literal["!="],
Literal[">"],
Literal[">="],
Literal["in"],
Literal["not in"],
Literal["is"],
Literal["is not"],
Literal["exception match"],
Literal["BAD"],
]
hasconst: list[int] hasconst: list[int]
hasname: list[int] hasname: list[int]
hasjrel: list[int] hasjrel: list[int]

View File

@ -239,7 +239,7 @@ class Values:
# __getattr__ doesn't exist, but anything passed as a default to __init__ # __getattr__ doesn't exist, but anything passed as a default to __init__
# is set on the instance. # is set on the instance.
def __getattr__(self, name: str) -> Any: ... def __getattr__(self, name: str) -> Any: ...
# TODO mypy infers -> object for __getattr__ if __setattr__ has `value: object` # TODO: mypy infers -> object for __getattr__ if __setattr__ has `value: object`
def __setattr__(self, name: str, value: Any, /) -> None: ... def __setattr__(self, name: str, value: Any, /) -> None: ...
def __eq__(self, other: object) -> bool: ... def __eq__(self, other: object) -> bool: ...

View File

@ -24,7 +24,7 @@ from builtins import OSError
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from subprocess import Popen from subprocess import Popen
from types import TracebackType from types import GenericAlias, TracebackType
from typing import ( from typing import (
IO, IO,
Any, Any,
@ -44,9 +44,6 @@ from typing_extensions import Self, TypeAlias, Unpack, deprecated
from . import path as _path from . import path as _path
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = [ __all__ = [
"F_OK", "F_OK",
"O_APPEND", "O_APPEND",
@ -155,14 +152,14 @@ __all__ = [
"umask", "umask",
"uname_result", "uname_result",
"unlink", "unlink",
"unsetenv",
"urandom", "urandom",
"utime", "utime",
"waitpid", "waitpid",
"waitstatus_to_exitcode",
"walk", "walk",
"write", "write",
] ]
if sys.version_info >= (3, 9):
__all__ += ["waitstatus_to_exitcode"]
if sys.platform == "darwin" and sys.version_info >= (3, 12): if sys.platform == "darwin" and sys.version_info >= (3, 12):
__all__ += ["PRIO_DARWIN_BG", "PRIO_DARWIN_NONUI", "PRIO_DARWIN_PROCESS", "PRIO_DARWIN_THREAD"] __all__ += ["PRIO_DARWIN_BG", "PRIO_DARWIN_NONUI", "PRIO_DARWIN_PROCESS", "PRIO_DARWIN_THREAD"]
if sys.platform == "darwin" and sys.version_info >= (3, 10): if sys.platform == "darwin" and sys.version_info >= (3, 10):
@ -194,6 +191,7 @@ if sys.platform == "linux":
"O_PATH", "O_PATH",
"O_RSYNC", "O_RSYNC",
"O_TMPFILE", "O_TMPFILE",
"P_PIDFD",
"RTLD_DEEPBIND", "RTLD_DEEPBIND",
"SCHED_BATCH", "SCHED_BATCH",
"SCHED_IDLE", "SCHED_IDLE",
@ -206,6 +204,7 @@ if sys.platform == "linux":
"getxattr", "getxattr",
"listxattr", "listxattr",
"memfd_create", "memfd_create",
"pidfd_open",
"removexattr", "removexattr",
"setxattr", "setxattr",
] ]
@ -256,8 +255,6 @@ if sys.platform == "linux" and sys.version_info >= (3, 10):
"eventfd_write", "eventfd_write",
"splice", "splice",
] ]
if sys.platform == "linux" and sys.version_info >= (3, 9):
__all__ += ["P_PIDFD", "pidfd_open"]
if sys.platform == "win32": if sys.platform == "win32":
__all__ += [ __all__ += [
"O_BINARY", "O_BINARY",
@ -280,6 +277,8 @@ if sys.platform != "win32":
"CLD_CONTINUED", "CLD_CONTINUED",
"CLD_DUMPED", "CLD_DUMPED",
"CLD_EXITED", "CLD_EXITED",
"CLD_KILLED",
"CLD_STOPPED",
"CLD_TRAPPED", "CLD_TRAPPED",
"EX_CANTCREAT", "EX_CANTCREAT",
"EX_CONFIG", "EX_CONFIG",
@ -431,8 +430,6 @@ if sys.platform != "win32" and sys.version_info >= (3, 11):
__all__ += ["login_tty"] __all__ += ["login_tty"]
if sys.platform != "win32" and sys.version_info >= (3, 10): if sys.platform != "win32" and sys.version_info >= (3, 10):
__all__ += ["O_FSYNC"] __all__ += ["O_FSYNC"]
if sys.platform != "win32" and sys.version_info >= (3, 9):
__all__ += ["CLD_KILLED", "CLD_STOPPED"]
if sys.platform != "darwin" and sys.platform != "win32": if sys.platform != "darwin" and sys.platform != "win32":
__all__ += [ __all__ += [
"POSIX_FADV_DONTNEED", "POSIX_FADV_DONTNEED",
@ -486,8 +483,6 @@ if sys.platform != "win32" or sys.version_info >= (3, 12):
__all__ += ["get_blocking", "set_blocking"] __all__ += ["get_blocking", "set_blocking"]
if sys.platform != "win32" or sys.version_info >= (3, 11): if sys.platform != "win32" or sys.version_info >= (3, 11):
__all__ += ["EX_OK"] __all__ += ["EX_OK"]
if sys.platform != "win32" or sys.version_info >= (3, 9):
__all__ += ["unsetenv"]
# This unnecessary alias is to work around various errors # This unnecessary alias is to work around various errors
path = _path path = _path
@ -550,7 +545,7 @@ if sys.platform != "win32":
P_PGID: int P_PGID: int
P_ALL: int P_ALL: int
if sys.platform == "linux" and sys.version_info >= (3, 9): if sys.platform == "linux":
P_PIDFD: int P_PIDFD: int
WEXITED: int WEXITED: int
@ -561,10 +556,8 @@ if sys.platform != "win32":
CLD_DUMPED: int CLD_DUMPED: int
CLD_TRAPPED: int CLD_TRAPPED: int
CLD_CONTINUED: int CLD_CONTINUED: int
CLD_KILLED: int
if sys.version_info >= (3, 9): CLD_STOPPED: int
CLD_KILLED: int
CLD_STOPPED: int
SCHED_OTHER: int SCHED_OTHER: int
SCHED_FIFO: int SCHED_FIFO: int
@ -698,29 +691,14 @@ class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]):
decodekey: _EnvironCodeFunc[AnyStr] decodekey: _EnvironCodeFunc[AnyStr]
encodevalue: _EnvironCodeFunc[AnyStr] encodevalue: _EnvironCodeFunc[AnyStr]
decodevalue: _EnvironCodeFunc[AnyStr] decodevalue: _EnvironCodeFunc[AnyStr]
if sys.version_info >= (3, 9): def __init__(
def __init__( self,
self, data: MutableMapping[AnyStr, AnyStr],
data: MutableMapping[AnyStr, AnyStr], encodekey: _EnvironCodeFunc[AnyStr],
encodekey: _EnvironCodeFunc[AnyStr], decodekey: _EnvironCodeFunc[AnyStr],
decodekey: _EnvironCodeFunc[AnyStr], encodevalue: _EnvironCodeFunc[AnyStr],
encodevalue: _EnvironCodeFunc[AnyStr], decodevalue: _EnvironCodeFunc[AnyStr],
decodevalue: _EnvironCodeFunc[AnyStr], ) -> None: ...
) -> None: ...
else:
putenv: Callable[[AnyStr, AnyStr], object]
unsetenv: Callable[[AnyStr, AnyStr], object]
def __init__(
self,
data: MutableMapping[AnyStr, AnyStr],
encodekey: _EnvironCodeFunc[AnyStr],
decodekey: _EnvironCodeFunc[AnyStr],
encodevalue: _EnvironCodeFunc[AnyStr],
decodevalue: _EnvironCodeFunc[AnyStr],
putenv: Callable[[AnyStr, AnyStr], object],
unsetenv: Callable[[AnyStr, AnyStr], object],
) -> None: ...
def setdefault(self, key: AnyStr, value: AnyStr) -> AnyStr: ... def setdefault(self, key: AnyStr, value: AnyStr) -> AnyStr: ...
def copy(self) -> dict[AnyStr, AnyStr]: ... def copy(self) -> dict[AnyStr, AnyStr]: ...
def __delitem__(self, key: AnyStr) -> None: ... def __delitem__(self, key: AnyStr) -> None: ...
@ -728,16 +706,15 @@ class _Environ(MutableMapping[AnyStr, AnyStr], Generic[AnyStr]):
def __setitem__(self, key: AnyStr, value: AnyStr) -> None: ... def __setitem__(self, key: AnyStr, value: AnyStr) -> None: ...
def __iter__(self) -> Iterator[AnyStr]: ... def __iter__(self) -> Iterator[AnyStr]: ...
def __len__(self) -> int: ... def __len__(self) -> int: ...
if sys.version_info >= (3, 9): def __or__(self, other: Mapping[_T1, _T2]) -> dict[AnyStr | _T1, AnyStr | _T2]: ...
def __or__(self, other: Mapping[_T1, _T2]) -> dict[AnyStr | _T1, AnyStr | _T2]: ... def __ror__(self, other: Mapping[_T1, _T2]) -> dict[AnyStr | _T1, AnyStr | _T2]: ...
def __ror__(self, other: Mapping[_T1, _T2]) -> dict[AnyStr | _T1, AnyStr | _T2]: ... # We use @overload instead of a Union for reasons similar to those given for
# We use @overload instead of a Union for reasons similar to those given for # overloading MutableMapping.update in stdlib/typing.pyi
# overloading MutableMapping.update in stdlib/typing.pyi # The type: ignore is needed due to incompatible __or__/__ior__ signatures
# The type: ignore is needed due to incompatible __or__/__ior__ signatures @overload # type: ignore[misc]
@overload # type: ignore[misc] def __ior__(self, other: Mapping[AnyStr, AnyStr]) -> Self: ...
def __ior__(self, other: Mapping[AnyStr, AnyStr]) -> Self: ... @overload
@overload def __ior__(self, other: Iterable[tuple[AnyStr, AnyStr]]) -> Self: ...
def __ior__(self, other: Iterable[tuple[AnyStr, AnyStr]]) -> Self: ...
environ: _Environ[str] environ: _Environ[str]
if sys.platform != "win32": if sys.platform != "win32":
@ -900,8 +877,7 @@ class DirEntry(Generic[AnyStr]):
def is_symlink(self) -> bool: ... def is_symlink(self) -> bool: ...
def stat(self, *, follow_symlinks: bool = True) -> stat_result: ... def stat(self, *, follow_symlinks: bool = True) -> stat_result: ...
def __fspath__(self) -> AnyStr: ... def __fspath__(self) -> AnyStr: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
def is_junction(self) -> bool: ... def is_junction(self) -> bool: ...
@ -1024,9 +1000,7 @@ if sys.platform != "win32":
else: else:
def putenv(name: str, value: str, /) -> None: ... def putenv(name: str, value: str, /) -> None: ...
def unsetenv(name: str, /) -> None: ...
if sys.version_info >= (3, 9):
def unsetenv(name: str, /) -> None: ...
_Opener: TypeAlias = Callable[[str, int], int] _Opener: TypeAlias = Callable[[str, int], int]
@ -1598,11 +1572,10 @@ if sys.platform == "linux":
def memfd_create(name: str, flags: int = ...) -> int: ... def memfd_create(name: str, flags: int = ...) -> int: ...
def copy_file_range(src: int, dst: int, count: int, offset_src: int | None = ..., offset_dst: int | None = ...) -> int: ... def copy_file_range(src: int, dst: int, count: int, offset_src: int | None = ..., offset_dst: int | None = ...) -> int: ...
if sys.version_info >= (3, 9): def waitstatus_to_exitcode(status: int) -> int: ...
def waitstatus_to_exitcode(status: int) -> int: ...
if sys.platform == "linux": if sys.platform == "linux":
def pidfd_open(pid: int, flags: int = ...) -> int: ... def pidfd_open(pid: int, flags: int = ...) -> int: ...
if sys.version_info >= (3, 12) and sys.platform == "linux": if sys.version_info >= (3, 12) and sys.platform == "linux":
PIDFD_NONBLOCK: Final = 2048 PIDFD_NONBLOCK: Final = 2048

View File

@ -14,13 +14,10 @@ from _typeshed import (
from collections.abc import Callable, Generator, Iterator, Sequence from collections.abc import Callable, Generator, Iterator, Sequence
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from os import PathLike, stat_result from os import PathLike, stat_result
from types import TracebackType from types import GenericAlias, TracebackType
from typing import IO, Any, BinaryIO, ClassVar, Literal, overload from typing import IO, Any, BinaryIO, ClassVar, Literal, overload
from typing_extensions import Never, Self, deprecated from typing_extensions import Never, Self, deprecated
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ["PurePath", "PurePosixPath", "PureWindowsPath", "Path", "PosixPath", "WindowsPath"] __all__ = ["PurePath", "PurePosixPath", "PureWindowsPath", "Path", "PosixPath", "WindowsPath"]
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
@ -68,7 +65,7 @@ class PurePath(PathLike[str]):
def is_reserved(self) -> bool: ... def is_reserved(self) -> bool: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
def is_relative_to(self, other: StrPath, /, *_deprecated: StrPath) -> bool: ... def is_relative_to(self, other: StrPath, /, *_deprecated: StrPath) -> bool: ...
elif sys.version_info >= (3, 9): else:
def is_relative_to(self, *other: StrPath) -> bool: ... def is_relative_to(self, *other: StrPath) -> bool: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
@ -82,16 +79,14 @@ class PurePath(PathLike[str]):
def relative_to(self, *other: StrPath) -> Self: ... def relative_to(self, *other: StrPath) -> Self: ...
def with_name(self, name: str) -> Self: ... def with_name(self, name: str) -> Self: ...
if sys.version_info >= (3, 9): def with_stem(self, stem: str) -> Self: ...
def with_stem(self, stem: str) -> Self: ...
def with_suffix(self, suffix: str) -> Self: ... def with_suffix(self, suffix: str) -> Self: ...
def joinpath(self, *other: StrPath) -> Self: ... def joinpath(self, *other: StrPath) -> Self: ...
@property @property
def parents(self) -> Sequence[Self]: ... def parents(self) -> Sequence[Self]: ...
@property @property
def parent(self) -> Self: ... def parent(self) -> Self: ...
if sys.version_info >= (3, 9) and sys.version_info < (3, 11): if sys.version_info < (3, 11):
def __class_getitem__(cls, type: Any) -> GenericAlias: ... def __class_getitem__(cls, type: Any) -> GenericAlias: ...
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
@ -247,8 +242,7 @@ class Path(PurePath):
else: else:
def is_mount(self) -> bool: ... def is_mount(self) -> bool: ...
if sys.version_info >= (3, 9): def readlink(self) -> Self: ...
def readlink(self) -> Self: ...
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
def rename(self, target: StrPath) -> Self: ... def rename(self, target: StrPath) -> Self: ...

View File

@ -48,6 +48,4 @@ def walk_packages(
path: Iterable[StrOrBytesPath] | None = None, prefix: str = "", onerror: Callable[[str], object] | None = None path: Iterable[StrOrBytesPath] | None = None, prefix: str = "", onerror: Callable[[str], object] | None = None
) -> Iterator[ModuleInfo]: ... ) -> Iterator[ModuleInfo]: ...
def get_data(package: str, resource: str) -> bytes | None: ... def get_data(package: str, resource: str) -> bytes | None: ...
def resolve_name(name: str) -> Any: ...
if sys.version_info >= (3, 9):
def resolve_name(name: str) -> Any: ...

View File

@ -15,40 +15,29 @@ def java_ver(
def system_alias(system: str, release: str, version: str) -> tuple[str, str, str]: ... def system_alias(system: str, release: str, version: str) -> tuple[str, str, str]: ...
def architecture(executable: str = sys.executable, bits: str = "", linkage: str = "") -> tuple[str, str]: ... def architecture(executable: str = sys.executable, bits: str = "", linkage: str = "") -> tuple[str, str]: ...
if sys.version_info >= (3, 9): # This class is not exposed. It calls itself platform.uname_result_base.
# This class is not exposed. It calls itself platform.uname_result_base. # At runtime it only has 5 fields.
# At runtime it only has 5 fields. @type_check_only
@type_check_only class _uname_result_base(NamedTuple):
class _uname_result_base(NamedTuple): system: str
system: str node: str
node: str release: str
release: str version: str
version: str machine: str
machine: str # This base class doesn't have this field at runtime, but claiming it
# This base class doesn't have this field at runtime, but claiming it # does is the least bad way to handle the situation. Nobody really
# does is the least bad way to handle the situation. Nobody really # sees this class anyway. See #13068
# sees this class anyway. See #13068 processor: str
processor: str
# uname_result emulates a 6-field named tuple, but the processor field # uname_result emulates a 6-field named tuple, but the processor field
# is lazily evaluated rather than being passed in to the constructor. # is lazily evaluated rather than being passed in to the constructor.
class uname_result(_uname_result_base): class uname_result(_uname_result_base):
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
__match_args__ = ("system", "node", "release", "version", "machine") # pyright: ignore[reportAssignmentType] __match_args__ = ("system", "node", "release", "version", "machine") # pyright: ignore[reportAssignmentType]
def __new__(_cls, system: str, node: str, release: str, version: str, machine: str) -> Self: ... def __new__(_cls, system: str, node: str, release: str, version: str, machine: str) -> Self: ...
@property @property
def processor(self) -> str: ... def processor(self) -> str: ...
else:
# On 3.8, uname_result is actually just a regular NamedTuple.
class uname_result(NamedTuple):
system: str
node: str
release: str
version: str
machine: str
processor: str
def uname() -> uname_result: ... def uname() -> uname_result: ...
def system() -> str: ... def system() -> str: ...

View File

@ -3,12 +3,10 @@ from _typeshed import ReadableBuffer
from collections.abc import Mapping, MutableMapping from collections.abc import Mapping, MutableMapping
from datetime import datetime from datetime import datetime
from enum import Enum from enum import Enum
from typing import IO, Any, ClassVar from typing import IO, Any
from typing_extensions import Self from typing_extensions import Self
__all__ = ["InvalidFileException", "FMT_XML", "FMT_BINARY", "load", "dump", "loads", "dumps", "UID"] __all__ = ["InvalidFileException", "FMT_XML", "FMT_BINARY", "load", "dump", "loads", "dumps", "UID"]
if sys.version_info < (3, 9):
__all__ += ["readPlist", "writePlist", "readPlistFromBytes", "writePlistToBytes", "Data"]
class PlistFormat(Enum): class PlistFormat(Enum):
FMT_XML = 1 FMT_XML = 1
@ -32,28 +30,12 @@ if sys.version_info >= (3, 13):
aware_datetime: bool = False, aware_datetime: bool = False,
) -> Any: ... ) -> Any: ...
elif sys.version_info >= (3, 9): else:
def load(fp: IO[bytes], *, fmt: PlistFormat | None = None, dict_type: type[MutableMapping[str, Any]] = ...) -> Any: ... def load(fp: IO[bytes], *, fmt: PlistFormat | None = None, dict_type: type[MutableMapping[str, Any]] = ...) -> Any: ...
def loads( def loads(
value: ReadableBuffer, *, fmt: PlistFormat | None = None, dict_type: type[MutableMapping[str, Any]] = ... value: ReadableBuffer, *, fmt: PlistFormat | None = None, dict_type: type[MutableMapping[str, Any]] = ...
) -> Any: ... ) -> Any: ...
else:
def load(
fp: IO[bytes],
*,
fmt: PlistFormat | None = None,
use_builtin_types: bool = True,
dict_type: type[MutableMapping[str, Any]] = ...,
) -> Any: ...
def loads(
value: ReadableBuffer,
*,
fmt: PlistFormat | None = None,
use_builtin_types: bool = True,
dict_type: type[MutableMapping[str, Any]] = ...,
) -> Any: ...
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
def dump( def dump(
value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | bytearray | datetime, value: Mapping[str, Any] | list[Any] | tuple[Any, ...] | str | bool | float | bytes | bytearray | datetime,
@ -90,18 +72,6 @@ else:
sort_keys: bool = True, sort_keys: bool = True,
) -> bytes: ... ) -> bytes: ...
if sys.version_info < (3, 9):
def readPlist(pathOrFile: str | IO[bytes]) -> Any: ...
def writePlist(value: Mapping[str, Any], pathOrFile: str | IO[bytes]) -> None: ...
def readPlistFromBytes(data: ReadableBuffer) -> Any: ...
def writePlistToBytes(value: Mapping[str, Any]) -> bytes: ...
if sys.version_info < (3, 9):
class Data:
data: bytes
def __init__(self, data: bytes) -> None: ...
__hash__: ClassVar[None] # type: ignore[assignment]
class UID: class UID:
data: int data: int
def __init__(self, data: int) -> None: ... def __init__(self, data: int) -> None: ...

View File

@ -6,6 +6,8 @@ if sys.platform != "win32":
CLD_CONTINUED as CLD_CONTINUED, CLD_CONTINUED as CLD_CONTINUED,
CLD_DUMPED as CLD_DUMPED, CLD_DUMPED as CLD_DUMPED,
CLD_EXITED as CLD_EXITED, CLD_EXITED as CLD_EXITED,
CLD_KILLED as CLD_KILLED,
CLD_STOPPED as CLD_STOPPED,
CLD_TRAPPED as CLD_TRAPPED, CLD_TRAPPED as CLD_TRAPPED,
EX_CANTCREAT as EX_CANTCREAT, EX_CANTCREAT as EX_CANTCREAT,
EX_CONFIG as EX_CONFIG, EX_CONFIG as EX_CONFIG,
@ -220,13 +222,11 @@ if sys.platform != "win32":
wait3 as wait3, wait3 as wait3,
wait4 as wait4, wait4 as wait4,
waitpid as waitpid, waitpid as waitpid,
waitstatus_to_exitcode as waitstatus_to_exitcode,
write as write, write as write,
writev as writev, writev as writev,
) )
if sys.version_info >= (3, 9):
from os import CLD_KILLED as CLD_KILLED, CLD_STOPPED as CLD_STOPPED, waitstatus_to_exitcode as waitstatus_to_exitcode
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
from os import O_FSYNC as O_FSYNC from os import O_FSYNC as O_FSYNC
@ -330,6 +330,7 @@ if sys.platform != "win32":
O_PATH as O_PATH, O_PATH as O_PATH,
O_RSYNC as O_RSYNC, O_RSYNC as O_RSYNC,
O_TMPFILE as O_TMPFILE, O_TMPFILE as O_TMPFILE,
P_PIDFD as P_PIDFD,
RTLD_DEEPBIND as RTLD_DEEPBIND, RTLD_DEEPBIND as RTLD_DEEPBIND,
SCHED_BATCH as SCHED_BATCH, SCHED_BATCH as SCHED_BATCH,
SCHED_IDLE as SCHED_IDLE, SCHED_IDLE as SCHED_IDLE,
@ -342,13 +343,11 @@ if sys.platform != "win32":
getxattr as getxattr, getxattr as getxattr,
listxattr as listxattr, listxattr as listxattr,
memfd_create as memfd_create, memfd_create as memfd_create,
pidfd_open as pidfd_open,
removexattr as removexattr, removexattr as removexattr,
setxattr as setxattr, setxattr as setxattr,
) )
if sys.version_info >= (3, 9):
from os import P_PIDFD as P_PIDFD, pidfd_open as pidfd_open
if sys.version_info >= (3, 10): if sys.version_info >= (3, 10):
from os import ( from os import (
EFD_CLOEXEC as EFD_CLOEXEC, EFD_CLOEXEC as EFD_CLOEXEC,

View File

@ -2,6 +2,7 @@ import sys
from _typeshed import StrOrBytesPath from _typeshed import StrOrBytesPath
from collections.abc import Iterable from collections.abc import Iterable
from cProfile import Profile as _cProfile from cProfile import Profile as _cProfile
from dataclasses import dataclass
from profile import Profile from profile import Profile
from typing import IO, Any, Literal, overload from typing import IO, Any, Literal, overload
from typing_extensions import Self, TypeAlias from typing_extensions import Self, TypeAlias
@ -11,10 +12,7 @@ if sys.version_info >= (3, 11):
else: else:
from enum import Enum from enum import Enum
if sys.version_info >= (3, 9): __all__ = ["Stats", "SortKey", "FunctionProfile", "StatsProfile"]
__all__ = ["Stats", "SortKey", "FunctionProfile", "StatsProfile"]
else:
__all__ = ["Stats", "SortKey"]
_Selector: TypeAlias = str | float | int _Selector: TypeAlias = str | float | int
@ -42,23 +40,20 @@ else:
STDNAME = "stdname" STDNAME = "stdname"
TIME = "time" TIME = "time"
if sys.version_info >= (3, 9): @dataclass(unsafe_hash=True)
from dataclasses import dataclass class FunctionProfile:
ncalls: str
tottime: float
percall_tottime: float
cumtime: float
percall_cumtime: float
file_name: str
line_number: int
@dataclass(unsafe_hash=True) @dataclass(unsafe_hash=True)
class FunctionProfile: class StatsProfile:
ncalls: str total_tt: float
tottime: float func_profiles: dict[str, FunctionProfile]
percall_tottime: float
cumtime: float
percall_cumtime: float
file_name: str
line_number: int
@dataclass(unsafe_hash=True)
class StatsProfile:
total_tt: float
func_profiles: dict[str, FunctionProfile]
_SortArgDict: TypeAlias = dict[str, tuple[tuple[tuple[int, int], ...], str]] _SortArgDict: TypeAlias = dict[str, tuple[tuple[tuple[int, int], ...], str]]
@ -85,9 +80,7 @@ class Stats:
def strip_dirs(self) -> Self: ... def strip_dirs(self) -> Self: ...
def calc_callees(self) -> None: ... def calc_callees(self) -> None: ...
def eval_print_amount(self, sel: _Selector, list: list[str], msg: str) -> tuple[list[str], str]: ... def eval_print_amount(self, sel: _Selector, list: list[str], msg: str) -> tuple[list[str], str]: ...
if sys.version_info >= (3, 9): def get_stats_profile(self) -> StatsProfile: ...
def get_stats_profile(self) -> StatsProfile: ...
def get_print_list(self, sel_list: Iterable[_Selector]) -> tuple[int, list[str]]: ... def get_print_list(self, sel_list: Iterable[_Selector]) -> tuple[int, list[str]]: ...
def print_stats(self, *amount: _Selector) -> Self: ... def print_stats(self, *amount: _Selector) -> Self: ...
def print_callees(self, *amount: _Selector) -> Self: ... def print_callees(self, *amount: _Selector) -> Self: ...

View File

@ -1,11 +1,9 @@
import sys import sys
from _queue import Empty as Empty, SimpleQueue as SimpleQueue from _queue import Empty as Empty, SimpleQueue as SimpleQueue
from threading import Condition, Lock from threading import Condition, Lock
from types import GenericAlias
from typing import Any, Generic, TypeVar from typing import Any, Generic, TypeVar
if sys.version_info >= (3, 9):
from types import GenericAlias
__all__ = ["Empty", "Full", "Queue", "PriorityQueue", "LifoQueue", "SimpleQueue"] __all__ = ["Empty", "Full", "Queue", "PriorityQueue", "LifoQueue", "SimpleQueue"]
if sys.version_info >= (3, 13): if sys.version_info >= (3, 13):
__all__ += ["ShutDown"] __all__ += ["ShutDown"]
@ -47,8 +45,7 @@ class Queue(Generic[_T]):
def qsize(self) -> int: ... def qsize(self) -> int: ...
def _qsize(self) -> int: ... def _qsize(self) -> int: ...
def task_done(self) -> None: ... def task_done(self) -> None: ...
if sys.version_info >= (3, 9): def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
class PriorityQueue(Queue[_T]): class PriorityQueue(Queue[_T]):
queue: list[_T] queue: list[_T]

View File

@ -30,10 +30,9 @@ __all__ = [
"getrandbits", "getrandbits",
"choices", "choices",
"SystemRandom", "SystemRandom",
"randbytes",
] ]
if sys.version_info >= (3, 9):
__all__ += ["randbytes"]
if sys.version_info >= (3, 12): if sys.version_info >= (3, 12):
__all__ += ["binomialvariate"] __all__ += ["binomialvariate"]
@ -41,25 +40,16 @@ _T = TypeVar("_T")
class Random(_random.Random): class Random(_random.Random):
VERSION: ClassVar[int] VERSION: ClassVar[int]
if sys.version_info >= (3, 9): def __init__(self, x: int | float | str | bytes | bytearray | None = None) -> None: ... # noqa: Y041
def __init__(self, x: int | float | str | bytes | bytearray | None = None) -> None: ... # noqa: Y041
else:
def __init__(self, x: Any = None) -> None: ...
# Using other `seed` types is deprecated since 3.9 and removed in 3.11 # Using other `seed` types is deprecated since 3.9 and removed in 3.11
# Ignore Y041, since random.seed doesn't treat int like a float subtype. Having an explicit # Ignore Y041, since random.seed doesn't treat int like a float subtype. Having an explicit
# int better documents conventional usage of random.seed. # int better documents conventional usage of random.seed.
if sys.version_info >= (3, 9): def seed(self, a: int | float | str | bytes | bytearray | None = None, version: int = 2) -> None: ... # type: ignore[override] # noqa: Y041
def seed(self, a: int | float | str | bytes | bytearray | None = None, version: int = 2) -> None: ... # type: ignore[override] # noqa: Y041
else:
def seed(self, a: Any = None, version: int = 2) -> None: ...
def getstate(self) -> tuple[Any, ...]: ... def getstate(self) -> tuple[Any, ...]: ...
def setstate(self, state: tuple[Any, ...]) -> None: ... def setstate(self, state: tuple[Any, ...]) -> None: ...
def randrange(self, start: int, stop: int | None = None, step: int = 1) -> int: ... def randrange(self, start: int, stop: int | None = None, step: int = 1) -> int: ...
def randint(self, a: int, b: int) -> int: ... def randint(self, a: int, b: int) -> int: ...
if sys.version_info >= (3, 9): def randbytes(self, n: int) -> bytes: ...
def randbytes(self, n: int) -> bytes: ...
def choice(self, seq: SupportsLenAndGetItem[_T]) -> _T: ... def choice(self, seq: SupportsLenAndGetItem[_T]) -> _T: ...
def choices( def choices(
self, self,
@ -75,12 +65,10 @@ class Random(_random.Random):
def shuffle(self, x: MutableSequence[Any], random: Callable[[], float] | None = None) -> None: ... def shuffle(self, x: MutableSequence[Any], random: Callable[[], float] | None = None) -> None: ...
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
def sample(self, population: Sequence[_T], k: int, *, counts: Iterable[int] | None = None) -> list[_T]: ... def sample(self, population: Sequence[_T], k: int, *, counts: Iterable[int] | None = None) -> list[_T]: ...
elif sys.version_info >= (3, 9): else:
def sample( def sample(
self, population: Sequence[_T] | AbstractSet[_T], k: int, *, counts: Iterable[int] | None = None self, population: Sequence[_T] | AbstractSet[_T], k: int, *, counts: Iterable[int] | None = None
) -> list[_T]: ... ) -> list[_T]: ...
else:
def sample(self, population: Sequence[_T] | AbstractSet[_T], k: int) -> list[_T]: ...
def uniform(self, a: float, b: float) -> float: ... def uniform(self, a: float, b: float) -> float: ...
def triangular(self, low: float = 0.0, high: float = 1.0, mode: float | None = None) -> float: ... def triangular(self, low: float = 0.0, high: float = 1.0, mode: float | None = None) -> float: ...
@ -137,5 +125,4 @@ weibullvariate = _inst.weibullvariate
getstate = _inst.getstate getstate = _inst.getstate
setstate = _inst.setstate setstate = _inst.setstate
getrandbits = _inst.getrandbits getrandbits = _inst.getrandbits
if sys.version_info >= (3, 9): randbytes = _inst.randbytes
randbytes = _inst.randbytes

Some files were not shown because too many files have changed in this diff Show More