Skip to content

Commit 78b09e2

Browse files
Merge branch 'main' into colour-stubs
2 parents be75a9a + c9e422d commit 78b09e2

256 files changed

Lines changed: 7593 additions & 1007 deletions

File tree

Some content is hidden

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

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ supported:
187187
uploads to PyPI. This should only be used in special cases, e.g. when the stubs
188188
break the upload.
189189
* `partial-stub` (optional): This field marks the type stub package as
190-
[partial](https://peps.python.org/pep-0561/#partial-stub-packages). This is for
191-
3rd-party stubs that don't cover the entirety of the package's public API.
190+
[partial](https://typing.python.org/en/latest/spec/distributing.html#partial-stub-packages).
191+
This is for 3rd-party stubs that don't cover the entirety of the package's public API.
192192
* `requires-python` (optional): The minimum version of Python required to install
193193
the type stub package. It must be in the form `>=3.*`. If omitted, the oldest
194194
Python version supported by typeshed is used.
@@ -441,7 +441,7 @@ these steps:
441441

442442
1. Open an issue explaining why the stubs should be removed.
443443
2. A maintainer will add the
444-
["stubs: removal" label](https://github.com/python/typeshed/labels/%22stubs%3A%20removal%22).
444+
["stubs: removal" label](https://github.com/python/typeshed/labels/stubs%3A%20removal).
445445
3. Open a PR that sets the `no-longer-updated` field in the `METADATA.toml`
446446
file to `true`.
447447
4. When a new version of the package was automatically uploaded to PyPI (which
@@ -452,7 +452,7 @@ for any stub obsoletions or removals.
452452

453453
### Marking PRs as "deferred"
454454

455-
We sometimes use the ["status: deferred" label](https://github.com/python/typeshed/labels/%22status%3A%20deferred%22)
455+
We sometimes use the ["status: deferred" label](https://github.com/python/typeshed/labels/status%3A%20deferred)
456456
to mark PRs and issues that we'd like to accept, but that are blocked by some
457457
external factor. Blockers can include:
458458

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,28 @@ target-version = ["py310"]
1111
skip-magic-trailing-comma = true
1212
preview = true
1313

14+
# Override `exclude` so that the `stdlib/venv` directory is not excluded
15+
# if you invoke Black "manually" (not using pre-commit). `venv` is one of
16+
# the directories that Black excludes by default if `tool.black.exclude`
17+
# is not set. See https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#exclude
18+
exclude = '''
19+
/(
20+
\.env|
21+
\.venv|
22+
env|
23+
\.git|
24+
\.mypy_cache
25+
)/
26+
'''
27+
1428
[tool.ruff]
1529
line-length = 130
1630
fix = true
31+
32+
# Override `exclude` so that the `stdlib/venv` directory is not excluded
33+
# if you invoke Ruff "manually" (not using pre-commit). `venv` is one of
34+
# the directories that Ruff excludes by default if `tool.ruff.exclude`
35+
# is not set. See https://docs.astral.sh/ruff/configuration/
1736
exclude = [
1837
# virtual environment
1938
".env",

pyrightconfig.stricter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"stubs/icalendar/icalendar/timezone/provider.pyi",
5757
"stubs/jsonschema",
5858
"stubs/jwcrypto",
59+
"stubs/kafka-python",
5960
"stubs/ldap3",
6061
"stubs/m3u8/m3u8/model.pyi",
6162
"stubs/Markdown",
@@ -78,7 +79,6 @@
7879
"stubs/psutil/psutil/__init__.pyi",
7980
"stubs/psycopg2",
8081
"stubs/pyasn1",
81-
"stubs/pycurl",
8282
"stubs/Pygments",
8383
"stubs/PyMySQL",
8484
"stubs/python-jose",

requirements-tests.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Type checkers that we test our stubs against. These should always
22
# be pinned to a specific version to make failure reproducible.
33
mypy==2.1.0
4-
pyright==1.1.409
4+
pyright==1.1.410
55

66
# Libraries used by our various scripts.
7-
aiohttp==3.13.5
7+
aiohttp==3.14.1
88
grpcio-tools>=1.76.0; python_version < "3.15" # For grpc_tools.protoc
99
mypy-protobuf==5.0.0; python_version < "3.15"
1010
packaging==26.0
@@ -18,7 +18,7 @@ termcolor>=2.3
1818
tomli==2.4.1; python_version < "3.11"
1919
tomlkit==0.14.0
2020
typing_extensions>=4.15.0rc1
21-
uv==0.11.6
21+
uv==0.11.15
2222

2323
# Utilities for typeshed infrastructure scripts.
2424
ts_utils @ file:lib

scripts/stubsabot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def get_origin_owner() -> str:
715715
output = subprocess.check_output(["git", "remote", "get-url", "origin"], text=True).strip()
716716
match = re.match(r"(git@github.com:|https://github.com/)(?P<owner>[^/]+)/(?P<repo>[^/\s]+)", output)
717717
assert match is not None, f"Couldn't identify origin's owner: {output!r}"
718-
assert match.group("repo").removesuffix(".git") == "typeshed", f'Unexpected repo: {match.group("repo")!r}'
718+
assert match.group("repo").removesuffix(".git") == "typeshed", f"Unexpected repo: {match.group('repo')!r}"
719719
return match.group("owner")
720720

721721

@@ -965,7 +965,7 @@ async def main() -> int:
965965
if args.distributions:
966966
dists_to_update = args.distributions
967967
else:
968-
dists_to_update = [path.name for path in STUBS_PATH.iterdir()]
968+
dists_to_update = sorted(path.name for path in STUBS_PATH.iterdir())
969969

970970
if args.action_level > ActionLevel.nothing:
971971
subprocess.run(["git", "update-index", "--refresh"], capture_output=True, check=False)

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,11 @@ _?ctypes.Union.__getattr__ # doesn't exist, but makes things easy if we pretend
236236
_?ctypes.Union.__setattr__ # doesn't exist, but makes things easy if we pretend it does
237237

238238
# Iterable classes that don't define __iter__ at runtime (usually iterable via __getitem__)
239-
# These would ideally be special-cased by type checkers; see https://github.com/python/mypy/issues/2220
239+
# These would ideally be special-cased by type checkers.
240+
# See https://github.com/python/mypy/issues/2220 and https://github.com/python/typeshed/issues/7813
240241
_?ctypes.Array.__iter__
242+
calendar._localized_day.__iter__
243+
calendar._localized_month.__iter__
241244

242245
dataclasses.KW_ONLY # white lies around defaults
243246

stdlib/@tests/stubtest_allowlists/linux.txt

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,78 @@ select.poll # Actually a function; we have a class so it can be used as a type
2929
# Bluetooth constants which aren't on the GitHub Actions runners, see #15207
3030
(_?socket\.AF_BLUETOOTH)?
3131
(_?socket\.BDADDR_ANY)?
32+
(_?socket\.BDADDR_BREDR)?
33+
(_?socket\.BDADDR_LE_PUBLIC)?
34+
(_?socket\.BDADDR_LE_RANDOM)?
3235
(_?socket\.BDADDR_LOCAL)?
36+
(_?socket\.BT_CHANNEL_POLICY)?
37+
(_?socket\.BT_CHANNEL_POLICY_BREDR_ONLY)?
38+
(_?socket\.BT_CHANNEL_POLICY_BREDR_PREFERRED)?
39+
(_?socket\.BT_CODEC)?
40+
(_?socket\.BT_DEFER_SETUP)?
41+
(_?socket\.BT_FLUSHABLE)?
42+
(_?socket\.BT_FLUSHABLE_OFF)?
43+
(_?socket\.BT_FLUSHABLE_ON)?
44+
(_?socket\.BT_ISO_QOS)?
45+
(_?socket\.BT_MODE)?
46+
(_?socket\.BT_MODE_BASIC)?
47+
(_?socket\.BT_MODE_ERTM)?
48+
(_?socket\.BT_MODE_EXT_FLOWCTL)?
49+
(_?socket\.BT_MODE_LE_FLOWCTL)?
50+
(_?socket\.BT_MODE_STREAMING)?
51+
(_?socket\.BT_PHY)?
52+
(_?socket\.BT_PHY_BR_1M_1SLOT)?
53+
(_?socket\.BT_PHY_BR_1M_3SLOT)?
54+
(_?socket\.BT_PHY_BR_1M_5SLOT)?
55+
(_?socket\.BT_PHY_EDR_2M_1SLOT)?
56+
(_?socket\.BT_PHY_EDR_2M_3SLOT)?
57+
(_?socket\.BT_PHY_EDR_2M_5SLOT)?
58+
(_?socket\.BT_PHY_EDR_3M_1SLOT)?
59+
(_?socket\.BT_PHY_EDR_3M_3SLOT)?
60+
(_?socket\.BT_PHY_EDR_3M_5SLOT)?
61+
(_?socket\.BT_PHY_LE_1M_RX)?
62+
(_?socket\.BT_PHY_LE_1M_TX)?
63+
(_?socket\.BT_PHY_LE_2M_RX)?
64+
(_?socket\.BT_PHY_LE_2M_TX)?
65+
(_?socket\.BT_PHY_LE_CODED_RX)?
66+
(_?socket\.BT_PHY_LE_CODED_TX)?
67+
(_?socket\.BT_PKT_STATUS)?
68+
(_?socket\.BT_POWER)?
69+
(_?socket\.BT_POWER_FORCE_ACTIVE_OFF)?
70+
(_?socket\.BT_POWER_FORCE_ACTIVE_ON)?
71+
(_?socket\.BT_RCVMTU)?
72+
(_?socket\.BT_SECURITY)?
73+
(_?socket\.BT_SECURITY_FIPS)?
74+
(_?socket\.BT_SECURITY_HIGH)?
75+
(_?socket\.BT_SECURITY_LOW)?
76+
(_?socket\.BT_SECURITY_MEDIUM)?
77+
(_?socket\.BT_SECURITY_SDP)?
78+
(_?socket\.BT_SNDMTU)?
79+
(_?socket\.BT_VOICE)?
80+
(_?socket\.BT_VOICE_CVSD_16BIT)?
81+
(_?socket\.BT_VOICE_TRANSPARENT)?
82+
(_?socket\.BT_VOICE_TRANSPARENT_16BIT)?
3383
(_?socket\.BTPROTO_HCI)?
3484
(_?socket\.BTPROTO_L2CAP)?
3585
(_?socket\.BTPROTO_RFCOMM)?
3686
(_?socket\.BTPROTO_SCO)?
87+
(_?socket\.HCI_CHANNEL_CONTROL)?
88+
(_?socket\.HCI_CHANNEL_LOGGING)?
89+
(_?socket\.HCI_CHANNEL_MONITOR)?
90+
(_?socket\.HCI_CHANNEL_RAW)?
91+
(_?socket\.HCI_CHANNEL_USER)?
92+
(_?socket\.HCI_DEV_NONE)?
93+
(_?socket\.L2CAP_LM)?
94+
(_?socket\.L2CAP_LM_AUTH)?
95+
(_?socket\.L2CAP_LM_ENCRYPT)?
96+
(_?socket\.L2CAP_LM_MASTER)?
97+
(_?socket\.L2CAP_LM_RELIABLE)?
98+
(_?socket\.L2CAP_LM_SECURE)?
99+
(_?socket\.L2CAP_LM_TRUSTED)?
100+
(_?socket\.SOL_BLUETOOTH)?
101+
(_?socket\.SOL_L2CAP)?
102+
(_?socket\.SOL_RFCOMM)?
103+
(_?socket\.SOL_SCO)?
37104

38105
# These seem like they should be available on Linux, but they're not
39106
# on GitHub Actions runners for some reason.

stdlib/_asyncio.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Task(Future[_T_co]): # type: ignore[type-var] # pyright: ignore[reportIn
9999
def get_event_loop() -> AbstractEventLoop: ...
100100
def get_running_loop() -> AbstractEventLoop: ...
101101
def _set_running_loop(loop: AbstractEventLoop | None, /) -> None: ...
102-
def _get_running_loop() -> AbstractEventLoop: ...
102+
def _get_running_loop() -> AbstractEventLoop | None: ...
103103
def _register_task(task: Task[Any]) -> None: ...
104104
def _unregister_task(task: Task[Any]) -> None: ...
105105
def _enter_task(loop: AbstractEventLoop, task: Task[Any]) -> None: ...

stdlib/_msi.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ if sys.platform == "win32":
5252
__init__: None # type: ignore[assignment]
5353

5454
def UuidCreate() -> str: ...
55-
def FCICreate(cabname: str, files: list[str], /) -> None: ...
55+
def FCICreate(cabname: str, files: list[tuple[str, str]], /) -> None: ...
5656
def OpenDatabase(path: str, persist: int, /) -> _Database: ...
5757
def CreateRecord(count: int, /) -> _Record: ...
5858

stdlib/_socket.pyi

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ _CMSGArg: TypeAlias = tuple[int, int, ReadableBuffer]
1111
# Addresses can be either tuples of varying lengths (AF_INET, AF_INET6,
1212
# AF_NETLINK, AF_TIPC) or strings/buffers (AF_UNIX).
1313
# See getsockaddrarg() in socketmodule.c.
14-
_Address: TypeAlias = tuple[Any, ...] | str | ReadableBuffer
14+
if sys.version_info >= (3, 14):
15+
# A bare int is accepted for Bluetooth HCI device IDs.
16+
_Address: TypeAlias = tuple[Any, ...] | str | ReadableBuffer | int
17+
else:
18+
_Address: TypeAlias = tuple[Any, ...] | str | ReadableBuffer
1519
_RetAddress: TypeAlias = Any
1620

1721
# ===== Constants =====
@@ -250,8 +254,75 @@ if sys.version_info >= (3, 14):
250254
TCP_QUICKACK: Final[int]
251255

252256
if sys.platform == "linux":
257+
BDADDR_BREDR: Final[int]
258+
BDADDR_LE_PUBLIC: Final[int]
259+
BDADDR_LE_RANDOM: Final[int]
260+
BT_CHANNEL_POLICY: Final[int]
261+
BT_CHANNEL_POLICY_BREDR_ONLY: Final[int]
262+
BT_CHANNEL_POLICY_BREDR_PREFERRED: Final[int]
263+
BT_CODEC: Final[int]
264+
BT_DEFER_SETUP: Final[int]
265+
BT_FLUSHABLE: Final[int]
266+
BT_FLUSHABLE_OFF: Final[int]
267+
BT_FLUSHABLE_ON: Final[int]
268+
BT_ISO_QOS: Final[int]
269+
BT_MODE: Final[int]
270+
BT_MODE_BASIC: Final[int]
271+
BT_MODE_ERTM: Final[int]
272+
BT_MODE_EXT_FLOWCTL: Final[int]
273+
BT_MODE_LE_FLOWCTL: Final[int]
274+
BT_MODE_STREAMING: Final[int]
275+
BT_PHY: Final[int]
276+
BT_PHY_BR_1M_1SLOT: Final[int]
277+
BT_PHY_BR_1M_3SLOT: Final[int]
278+
BT_PHY_BR_1M_5SLOT: Final[int]
279+
BT_PHY_EDR_2M_1SLOT: Final[int]
280+
BT_PHY_EDR_2M_3SLOT: Final[int]
281+
BT_PHY_EDR_2M_5SLOT: Final[int]
282+
BT_PHY_EDR_3M_1SLOT: Final[int]
283+
BT_PHY_EDR_3M_3SLOT: Final[int]
284+
BT_PHY_EDR_3M_5SLOT: Final[int]
285+
BT_PHY_LE_1M_RX: Final[int]
286+
BT_PHY_LE_1M_TX: Final[int]
287+
BT_PHY_LE_2M_RX: Final[int]
288+
BT_PHY_LE_2M_TX: Final[int]
289+
BT_PHY_LE_CODED_RX: Final[int]
290+
BT_PHY_LE_CODED_TX: Final[int]
291+
BT_PKT_STATUS: Final[int]
292+
BT_POWER: Final[int]
293+
BT_POWER_FORCE_ACTIVE_OFF: Final[int]
294+
BT_POWER_FORCE_ACTIVE_ON: Final[int]
295+
BT_RCVMTU: Final[int]
296+
BT_SECURITY: Final[int]
297+
BT_SECURITY_FIPS: Final[int]
298+
BT_SECURITY_HIGH: Final[int]
299+
BT_SECURITY_LOW: Final[int]
300+
BT_SECURITY_MEDIUM: Final[int]
301+
BT_SECURITY_SDP: Final[int]
302+
BT_SNDMTU: Final[int]
303+
BT_VOICE: Final[int]
304+
BT_VOICE_CVSD_16BIT: Final[int]
305+
BT_VOICE_TRANSPARENT: Final[int]
306+
BT_VOICE_TRANSPARENT_16BIT: Final[int]
307+
HCI_CHANNEL_CONTROL: Final[int]
308+
HCI_CHANNEL_LOGGING: Final[int]
309+
HCI_CHANNEL_MONITOR: Final[int]
310+
HCI_CHANNEL_RAW: Final[int]
311+
HCI_CHANNEL_USER: Final[int]
312+
HCI_DEV_NONE: Final[int]
253313
IP_FREEBIND: Final[int]
254314
IP_RECVORIGDSTADDR: Final[int]
315+
L2CAP_LM: Final[int]
316+
L2CAP_LM_AUTH: Final[int]
317+
L2CAP_LM_ENCRYPT: Final[int]
318+
L2CAP_LM_MASTER: Final[int]
319+
L2CAP_LM_RELIABLE: Final[int]
320+
L2CAP_LM_SECURE: Final[int]
321+
L2CAP_LM_TRUSTED: Final[int]
322+
SOL_BLUETOOTH: Final[int]
323+
SOL_L2CAP: Final[int]
324+
SOL_RFCOMM: Final[int]
325+
SOL_SCO: Final[int]
255326
VMADDR_CID_LOCAL: Final[int]
256327

257328
if sys.platform != "win32" and sys.platform != "darwin":

0 commit comments

Comments
 (0)