Skip to content

Commit ac7b177

Browse files
Sync vendored typeshed stubs (#12899)
Close and reopen this PR to trigger CI Co-authored-by: typeshedbot <>
1 parent e4c2859 commit ac7b177

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+653
-172
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4ef2d66663fc080fefa379e6ae5fc45d4f8b54eb
1+
1ace5718deaf3041f8e3d1dc9c9e8a8e830e517f

crates/red_knot_python_semantic/vendor/typeshed/stdlib/_ast.pyi

+5-3
Original file line numberDiff line numberDiff line change
@@ -753,9 +753,11 @@ class Constant(expr):
753753
__match_args__ = ("value", "kind")
754754
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
755755
kind: str | None
756-
# Aliases for value, for backwards compatibility
757-
s: Any
758-
n: int | float | complex
756+
if sys.version_info < (3, 14):
757+
# Aliases for value, for backwards compatibility
758+
s: Any
759+
n: int | float | complex
760+
759761
def __init__(self, value: Any, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
760762

761763
class NamedExpr(expr):

crates/red_knot_python_semantic/vendor/typeshed/stdlib/_collections_abc.pyi

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import sys
22
from abc import abstractmethod
33
from types import MappingProxyType
4-
from typing import ( # noqa: Y022,Y038,Y057
4+
from typing import ( # noqa: Y022,Y038
55
AbstractSet as Set,
66
AsyncGenerator as AsyncGenerator,
77
AsyncIterable as AsyncIterable,
88
AsyncIterator as AsyncIterator,
99
Awaitable as Awaitable,
10-
ByteString as ByteString,
1110
Callable as Callable,
1211
Collection as Collection,
1312
Container as Container,
@@ -59,8 +58,12 @@ __all__ = [
5958
"ValuesView",
6059
"Sequence",
6160
"MutableSequence",
62-
"ByteString",
6361
]
62+
if sys.version_info < (3, 14):
63+
from typing import ByteString as ByteString # noqa: Y057
64+
65+
__all__ += ["ByteString"]
66+
6467
if sys.version_info >= (3, 12):
6568
__all__ += ["Buffer"]
6669

crates/red_knot_python_semantic/vendor/typeshed/stdlib/_ctypes.pyi

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class _CDataMeta(type):
5151
# By default mypy complains about the following two methods, because strictly speaking cls
5252
# might not be a Type[_CT]. However this can never actually happen, because the only class that
5353
# uses _CDataMeta as its metaclass is _CData. So it's safe to ignore the errors here.
54-
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc]
55-
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc]
54+
def __mul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
55+
def __rmul__(cls: type[_CT], other: int) -> type[Array[_CT]]: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
5656

5757
class _CData(metaclass=_CDataMeta):
5858
_b_base_: int

crates/red_knot_python_semantic/vendor/typeshed/stdlib/argparse.pyi

+11-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,17 @@ class Action(_AttributeHolder):
357357

358358
if sys.version_info >= (3, 12):
359359
class BooleanOptionalAction(Action):
360-
if sys.version_info >= (3, 13):
360+
if sys.version_info >= (3, 14):
361+
def __init__(
362+
self,
363+
option_strings: Sequence[str],
364+
dest: str,
365+
default: bool | None = None,
366+
required: bool = False,
367+
help: str | None = None,
368+
deprecated: bool = False,
369+
) -> None: ...
370+
elif sys.version_info >= (3, 13):
361371
@overload
362372
def __init__(
363373
self,

crates/red_knot_python_semantic/vendor/typeshed/stdlib/ast.pyi

+18-17
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,28 @@ class _ABC(type):
1010
if sys.version_info >= (3, 9):
1111
def __init__(cls, *args: Unused) -> None: ...
1212

13-
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
14-
class Num(Constant, metaclass=_ABC):
15-
value: int | float | complex
13+
if sys.version_info < (3, 14):
14+
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
15+
class Num(Constant, metaclass=_ABC):
16+
value: int | float | complex
1617

17-
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
18-
class Str(Constant, metaclass=_ABC):
19-
value: str
20-
# Aliases for value, for backwards compatibility
21-
s: str
18+
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
19+
class Str(Constant, metaclass=_ABC):
20+
value: str
21+
# Aliases for value, for backwards compatibility
22+
s: str
2223

23-
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
24-
class Bytes(Constant, metaclass=_ABC):
25-
value: bytes
26-
# Aliases for value, for backwards compatibility
27-
s: bytes
24+
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
25+
class Bytes(Constant, metaclass=_ABC):
26+
value: bytes
27+
# Aliases for value, for backwards compatibility
28+
s: bytes
2829

29-
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
30-
class NameConstant(Constant, metaclass=_ABC): ...
30+
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
31+
class NameConstant(Constant, metaclass=_ABC): ...
3132

32-
@deprecated("Replaced by ast.Constant; removal scheduled for Python 3.14")
33-
class Ellipsis(Constant, metaclass=_ABC): ...
33+
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
34+
class Ellipsis(Constant, metaclass=_ABC): ...
3435

3536
if sys.version_info >= (3, 9):
3637
class slice(AST): ...

crates/red_knot_python_semantic/vendor/typeshed/stdlib/asyncio/tasks.pyi

+6-6
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ if sys.version_info >= (3, 10):
151151
@overload
152152
def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap]
153153
@overload
154-
def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[overload-overlap]
154+
def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ...
155155
@overload
156-
def gather( # type: ignore[overload-overlap]
156+
def gather(
157157
coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool
158158
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ...
159159
@overload
160-
def gather( # type: ignore[overload-overlap]
160+
def gather(
161161
coro_or_future1: _FutureLike[_T1],
162162
coro_or_future2: _FutureLike[_T2],
163163
coro_or_future3: _FutureLike[_T3],
@@ -166,7 +166,7 @@ if sys.version_info >= (3, 10):
166166
return_exceptions: bool,
167167
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ...
168168
@overload
169-
def gather( # type: ignore[overload-overlap]
169+
def gather(
170170
coro_or_future1: _FutureLike[_T1],
171171
coro_or_future2: _FutureLike[_T2],
172172
coro_or_future3: _FutureLike[_T3],
@@ -176,7 +176,7 @@ if sys.version_info >= (3, 10):
176176
return_exceptions: bool,
177177
) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ...
178178
@overload
179-
def gather( # type: ignore[overload-overlap]
179+
def gather(
180180
coro_or_future1: _FutureLike[_T1],
181181
coro_or_future2: _FutureLike[_T2],
182182
coro_or_future3: _FutureLike[_T3],
@@ -189,7 +189,7 @@ if sys.version_info >= (3, 10):
189189
tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException]
190190
]: ...
191191
@overload
192-
def gather( # type: ignore[overload-overlap]
192+
def gather(
193193
coro_or_future1: _FutureLike[_T1],
194194
coro_or_future2: _FutureLike[_T2],
195195
coro_or_future3: _FutureLike[_T3],

crates/red_knot_python_semantic/vendor/typeshed/stdlib/asyncio/unix_events.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ if sys.platform != "win32":
159159

160160
class _UnixSelectorEventLoop(BaseSelectorEventLoop):
161161
if sys.version_info >= (3, 13):
162-
async def create_unix_server( # type: ignore[override]
162+
async def create_unix_server(
163163
self,
164164
protocol_factory: _ProtocolFactory,
165165
path: StrPath | None = None,

crates/red_knot_python_semantic/vendor/typeshed/stdlib/builtins.pyi

+2-3
Original file line numberDiff line numberDiff line change
@@ -1744,17 +1744,16 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit
17441744
# without creating many false-positive errors (see #7578).
17451745
# Instead, we special-case the most common examples of this: bool and literal integers.
17461746
@overload
1747-
def sum(iterable: Iterable[bool | _LiteralInteger], /, start: int = 0) -> int: ... # type: ignore[overload-overlap]
1747+
def sum(iterable: Iterable[bool | _LiteralInteger], /, start: int = 0) -> int: ...
17481748
@overload
17491749
def sum(iterable: Iterable[_SupportsSumNoDefaultT], /) -> _SupportsSumNoDefaultT | Literal[0]: ...
17501750
@overload
17511751
def sum(iterable: Iterable[_AddableT1], /, start: _AddableT2) -> _AddableT1 | _AddableT2: ...
17521752

17531753
# The argument to `vars()` has to have a `__dict__` attribute, so the second overload can't be annotated with `object`
17541754
# (A "SupportsDunderDict" protocol doesn't work)
1755-
# Use a type: ignore to make complaints about overlapping overloads go away
17561755
@overload
1757-
def vars(object: type, /) -> types.MappingProxyType[str, Any]: ... # type: ignore[overload-overlap]
1756+
def vars(object: type, /) -> types.MappingProxyType[str, Any]: ...
17581757
@overload
17591758
def vars(object: Any = ..., /) -> dict[str, Any]: ...
17601759

crates/red_knot_python_semantic/vendor/typeshed/stdlib/contextlib.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class AbstractAsyncContextManager(Protocol[_T_co, _ExitT_co]):
5555
) -> _ExitT_co: ...
5656

5757
class ContextDecorator:
58+
def _recreate_cm(self) -> Self: ...
5859
def __call__(self, func: _F) -> _F: ...
5960

6061
class _GeneratorContextManager(AbstractContextManager[_T_co, bool | None], ContextDecorator):
@@ -80,6 +81,7 @@ if sys.version_info >= (3, 10):
8081
_AF = TypeVar("_AF", bound=Callable[..., Awaitable[Any]])
8182

8283
class AsyncContextDecorator:
84+
def _recreate_cm(self) -> Self: ...
8385
def __call__(self, func: _AF) -> _AF: ...
8486

8587
class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co, bool | None], AsyncContextDecorator):

crates/red_knot_python_semantic/vendor/typeshed/stdlib/ctypes/_endian.pyi

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import sys
2-
from _ctypes import RTLD_GLOBAL as RTLD_GLOBAL, RTLD_LOCAL as RTLD_LOCAL, Structure, Union
3-
from ctypes import DEFAULT_MODE as DEFAULT_MODE, cdll as cdll, pydll as pydll, pythonapi as pythonapi
4-
5-
if sys.version_info >= (3, 12):
6-
from _ctypes import SIZEOF_TIME_T as SIZEOF_TIME_T
7-
8-
if sys.platform == "win32":
9-
from ctypes import oledll as oledll, windll as windll
2+
from ctypes import Structure, Union
103

114
# At runtime, the native endianness is an alias for Structure,
125
# while the other is a subclass with a metaclass added in.

crates/red_knot_python_semantic/vendor/typeshed/stdlib/dataclasses.pyi

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from _typeshed import DataclassInstance
55
from builtins import type as Type # alias to avoid name clashes with fields named "type"
66
from collections.abc import Callable, Iterable, Mapping
77
from typing import Any, Generic, Literal, Protocol, TypeVar, overload
8-
from typing_extensions import TypeAlias, TypeIs
8+
from typing_extensions import Never, TypeAlias, TypeIs
99

1010
if sys.version_info >= (3, 9):
1111
from types import GenericAlias
@@ -213,6 +213,10 @@ else:
213213
) -> Any: ...
214214

215215
def fields(class_or_instance: DataclassInstance | type[DataclassInstance]) -> tuple[Field[Any], ...]: ...
216+
217+
# HACK: `obj: Never` typing matches if object argument is using `Any` type.
218+
@overload
219+
def is_dataclass(obj: Never) -> TypeIs[DataclassInstance | type[DataclassInstance]]: ... # type: ignore[narrowed-type-not-subtype] # pyright: ignore[reportGeneralTypeIssues]
216220
@overload
217221
def is_dataclass(obj: type) -> TypeIs[type[DataclassInstance]]: ...
218222
@overload

crates/red_knot_python_semantic/vendor/typeshed/stdlib/distutils/cmd.pyi

+120
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused
22
from abc import abstractmethod
33
from collections.abc import Callable, Iterable
4+
from distutils.command.bdist import bdist
5+
from distutils.command.bdist_dumb import bdist_dumb
6+
from distutils.command.bdist_rpm import bdist_rpm
7+
from distutils.command.build import build
8+
from distutils.command.build_clib import build_clib
9+
from distutils.command.build_ext import build_ext
10+
from distutils.command.build_py import build_py
11+
from distutils.command.build_scripts import build_scripts
12+
from distutils.command.check import check
13+
from distutils.command.clean import clean
14+
from distutils.command.config import config
15+
from distutils.command.install import install
16+
from distutils.command.install_data import install_data
17+
from distutils.command.install_egg_info import install_egg_info
18+
from distutils.command.install_headers import install_headers
19+
from distutils.command.install_lib import install_lib
20+
from distutils.command.install_scripts import install_scripts
21+
from distutils.command.register import register
22+
from distutils.command.sdist import sdist
23+
from distutils.command.upload import upload
424
from distutils.dist import Distribution
525
from distutils.file_util import _BytesPathT, _StrPathT
626
from typing import Any, ClassVar, Literal, TypeVar, overload
@@ -28,8 +48,108 @@ class Command:
2848
def ensure_dirname(self, option: str) -> None: ...
2949
def get_command_name(self) -> str: ...
3050
def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ...
51+
# NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst.
52+
@overload
53+
def get_finalized_command(self, command: Literal["bdist"], create: bool | Literal[0, 1] = 1) -> bdist: ...
54+
@overload
55+
def get_finalized_command(self, command: Literal["bdist_dumb"], create: bool | Literal[0, 1] = 1) -> bdist_dumb: ...
56+
@overload
57+
def get_finalized_command(self, command: Literal["bdist_rpm"], create: bool | Literal[0, 1] = 1) -> bdist_rpm: ...
58+
@overload
59+
def get_finalized_command(self, command: Literal["build"], create: bool | Literal[0, 1] = 1) -> build: ...
60+
@overload
61+
def get_finalized_command(self, command: Literal["build_clib"], create: bool | Literal[0, 1] = 1) -> build_clib: ...
62+
@overload
63+
def get_finalized_command(self, command: Literal["build_ext"], create: bool | Literal[0, 1] = 1) -> build_ext: ...
64+
@overload
65+
def get_finalized_command(self, command: Literal["build_py"], create: bool | Literal[0, 1] = 1) -> build_py: ...
66+
@overload
67+
def get_finalized_command(self, command: Literal["build_scripts"], create: bool | Literal[0, 1] = 1) -> build_scripts: ...
68+
@overload
69+
def get_finalized_command(self, command: Literal["check"], create: bool | Literal[0, 1] = 1) -> check: ...
70+
@overload
71+
def get_finalized_command(self, command: Literal["clean"], create: bool | Literal[0, 1] = 1) -> clean: ...
72+
@overload
73+
def get_finalized_command(self, command: Literal["config"], create: bool | Literal[0, 1] = 1) -> config: ...
74+
@overload
75+
def get_finalized_command(self, command: Literal["install"], create: bool | Literal[0, 1] = 1) -> install: ...
76+
@overload
77+
def get_finalized_command(self, command: Literal["install_data"], create: bool | Literal[0, 1] = 1) -> install_data: ...
78+
@overload
79+
def get_finalized_command(
80+
self, command: Literal["install_egg_info"], create: bool | Literal[0, 1] = 1
81+
) -> install_egg_info: ...
82+
@overload
83+
def get_finalized_command(self, command: Literal["install_headers"], create: bool | Literal[0, 1] = 1) -> install_headers: ...
84+
@overload
85+
def get_finalized_command(self, command: Literal["install_lib"], create: bool | Literal[0, 1] = 1) -> install_lib: ...
86+
@overload
87+
def get_finalized_command(self, command: Literal["install_scripts"], create: bool | Literal[0, 1] = 1) -> install_scripts: ...
88+
@overload
89+
def get_finalized_command(self, command: Literal["register"], create: bool | Literal[0, 1] = 1) -> register: ...
90+
@overload
91+
def get_finalized_command(self, command: Literal["sdist"], create: bool | Literal[0, 1] = 1) -> sdist: ...
92+
@overload
93+
def get_finalized_command(self, command: Literal["upload"], create: bool | Literal[0, 1] = 1) -> upload: ...
94+
@overload
3195
def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ...
3296
@overload
97+
def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist: ...
98+
@overload
99+
def reinitialize_command(
100+
self, command: Literal["bdist_dumb"], reinit_subcommands: bool | Literal[0, 1] = 0
101+
) -> bdist_dumb: ...
102+
@overload
103+
def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist_rpm: ...
104+
@overload
105+
def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build: ...
106+
@overload
107+
def reinitialize_command(
108+
self, command: Literal["build_clib"], reinit_subcommands: bool | Literal[0, 1] = 0
109+
) -> build_clib: ...
110+
@overload
111+
def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_ext: ...
112+
@overload
113+
def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_py: ...
114+
@overload
115+
def reinitialize_command(
116+
self, command: Literal["build_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0
117+
) -> build_scripts: ...
118+
@overload
119+
def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool | Literal[0, 1] = 0) -> check: ...
120+
@overload
121+
def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool | Literal[0, 1] = 0) -> clean: ...
122+
@overload
123+
def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool | Literal[0, 1] = 0) -> config: ...
124+
@overload
125+
def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool | Literal[0, 1] = 0) -> install: ...
126+
@overload
127+
def reinitialize_command(
128+
self, command: Literal["install_data"], reinit_subcommands: bool | Literal[0, 1] = 0
129+
) -> install_data: ...
130+
@overload
131+
def reinitialize_command(
132+
self, command: Literal["install_egg_info"], reinit_subcommands: bool | Literal[0, 1] = 0
133+
) -> install_egg_info: ...
134+
@overload
135+
def reinitialize_command(
136+
self, command: Literal["install_headers"], reinit_subcommands: bool | Literal[0, 1] = 0
137+
) -> install_headers: ...
138+
@overload
139+
def reinitialize_command(
140+
self, command: Literal["install_lib"], reinit_subcommands: bool | Literal[0, 1] = 0
141+
) -> install_lib: ...
142+
@overload
143+
def reinitialize_command(
144+
self, command: Literal["install_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0
145+
) -> install_scripts: ...
146+
@overload
147+
def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool | Literal[0, 1] = 0) -> register: ...
148+
@overload
149+
def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> sdist: ...
150+
@overload
151+
def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool | Literal[0, 1] = 0) -> upload: ...
152+
@overload
33153
def reinitialize_command(self, command: str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ...
34154
@overload
35155
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool | Literal[0, 1] = 0) -> _CommandT: ...

0 commit comments

Comments
 (0)