Skip to content

Commit a983ca1

Browse files
authored
Merge branch 'main' into feature/simple-websocket
2 parents 4edb60b + be34e92 commit a983ca1

File tree

95 files changed

+1116
-702
lines changed

Some content is hidden

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

95 files changed

+1116
-702
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def foo(x: Incomplete | None) -> list[Incomplete]: ...
311311
### What to do when a project's documentation and implementation disagree
312312

313313
Type stubs are meant to be external type annotations for a given
314-
library. While they are useful documentation in its own merit, they
314+
library. While they are useful documentation in their own right, they
315315
augment the project's concrete implementation, not the project's
316316
documentation. Whenever you find them disagreeing, model the type
317317
information after the actual implementation and file an issue on the

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
## About
88

99
Typeshed contains external type annotations for the Python standard library
10-
and Python builtins, as well as third party packages as contributed by
10+
and Python builtins, as well as third-party packages that are contributed by
1111
people external to those projects.
1212

13-
This data can e.g. be used for static analysis, type checking, type inference,
13+
This data can, e.g., be used for static analysis, type checking, type inference,
1414
and autocompletion.
1515

1616
For information on how to use typeshed, read below. Information for
@@ -29,8 +29,8 @@ If you're just using a type checker (e.g. [mypy](https://github.com/python/mypy/
2929
[pyright](https://github.com/microsoft/pyright), or PyCharm's built-in type
3030
checker), as opposed to
3131
developing it, you don't need to interact with the typeshed repo at
32-
all: a copy of standard library part of typeshed is bundled with type checkers.
33-
And type stubs for third party packages and modules you are using can
32+
all: a copy of the standard library part of typeshed is bundled with type checkers.
33+
And type stubs for third-party packages and modules you are using can
3434
be installed from PyPI. For example, if you are using `html5lib` and `requests`,
3535
you can install the type stubs using
3636

@@ -70,7 +70,7 @@ package you're using, each with its own tradeoffs:
7070
type checking due to changes in the stubs.
7171

7272
Another risk of this strategy is that stubs often lag behind
73-
the package being stubbed. You might want to force the package being stubbed
73+
the package that is being stubbed. You might want to force the package being stubbed
7474
to a certain minimum version because it fixes a critical bug, but if
7575
correspondingly updated stubs have not been released, your type
7676
checking results may not be fully accurate.
@@ -119,6 +119,6 @@ a review of your type annotations or stubs outside of typeshed, head over to
119119
[our discussion forum](https://github.com/python/typing/discussions).
120120
For less formal discussion, try the typing chat room on
121121
[gitter.im](https://gitter.im/python/typing). Some typeshed maintainers
122-
are almost always present; feel free to find us there and we're happy
122+
are almost always present; feel free to find us there, and we're happy
123123
to chat. Substantive technical discussion will be directed to the
124124
issue tracker.

requirements-tests.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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==1.18.2
4-
pyright==1.1.406
4+
pyright==1.1.407
55

66
# Libraries used by our various scripts.
77
aiohttp==3.12.15
@@ -19,7 +19,7 @@ termcolor>=2.3
1919
tomli==2.2.1; python_version < "3.11"
2020
tomlkit==0.13.3
2121
typing_extensions>=4.15.0rc1
22-
uv==0.8.22
22+
uv==0.9.6
2323

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

scripts/stubsabot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def __str__(self) -> str:
161161
@dataclass
162162
class Remove:
163163
distribution: str
164-
reason: str
164+
reason: Literal["ships py.typed file", "unmaintained"]
165165
links: dict[str, str]
166166

167167
def __str__(self) -> str:
@@ -171,7 +171,7 @@ def __str__(self) -> str:
171171
@dataclass
172172
class NoUpdate:
173173
distribution: str
174-
reason: str
174+
reason: Literal["obsolete", "no longer updated", "up to date"]
175175

176176
def __str__(self) -> str:
177177
return f"{colored('skipping', 'green')} ({self.reason})"
@@ -642,7 +642,7 @@ async def determine_action_no_error_handling(
642642
"Typeshed release": f"{pypi_info.pypi_root}",
643643
"Typeshed stubs": f"https://github.com/{TYPESHED_OWNER}/typeshed/tree/main/stubs/{stub_info.distribution}",
644644
}
645-
return Remove(stub_info.distribution, reason="older than 6 months", links=links)
645+
return Remove(stub_info.distribution, reason="ships py.typed file", links=links)
646646
else:
647647
return NoUpdate(stub_info.distribution, "obsolete")
648648
if stub_info.no_longer_updated:
@@ -654,7 +654,7 @@ async def determine_action_no_error_handling(
654654
"Typeshed release": f"{pypi_info.pypi_root}",
655655
"Typeshed stubs": f"https://github.com/{TYPESHED_OWNER}/typeshed/tree/main/stubs/{stub_info.distribution}",
656656
}
657-
return Remove(stub_info.distribution, reason="no longer updated", links=links)
657+
return Remove(stub_info.distribution, reason="unmaintained", links=links)
658658
else:
659659
return NoUpdate(stub_info.distribution, "no longer updated")
660660

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ sys.ps1 # Available in interactive mode
170170
sys.ps2 # Available in interactive mode
171171
sys.tracebacklimit # Must be set first
172172

173+
# This is only present if Python was built with zlib-ng.
174+
(zlib\.ZLIBNG_VERSION)?
175+
(compression\.zlib\.ZLIBNG_VERSION)?
176+
173177

174178
# ==========================================================
175179
# Other allowlist entries that cannot or should not be fixed
@@ -233,7 +237,6 @@ asyncio.locks.Condition.release
233237
builtins.memoryview.__contains__ # C type that implements __getitem__
234238
builtins.reveal_locals # Builtins that type checkers pretends exist
235239
builtins.reveal_type # Builtins that type checkers pretends exist
236-
builtins.type.__dict__ # read-only but not actually a property; stubtest thinks it's a mutable attribute.
237240

238241
# The following CodecInfo properties are added in __new__
239242
codecs.CodecInfo.decode

stdlib/@tests/stubtest_allowlists/darwin-py313.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@
33
# =======
44

55
(mmap.MAP_32BIT)? # Exists locally on MacOS but not on GitHub
6+
7+
# ================
8+
# Unclear problems
9+
# ================
10+
11+
# Added in 3.11.1, flagged by stubtest on Python < 3.14 for unknown reasons
12+
errno.ENOTCAPABLE

stdlib/@tests/stubtest_allowlists/linux-py39.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
# while being inspected by stubtest. Fixed in Python 3.10.
77
select.epoll.register
88

9+
# According to stubtest, these are sometimes not present at runtime, starting
10+
# with Python 3.9.24. Which is not true.
11+
(_frozen_importlib_external.PathFinder.find_distributions)?
12+
(importlib._bootstrap_external.PathFinder.find_distributions)?
13+
(importlib.machinery.PathFinder.find_distributions)?
14+
915

1016
# =============================================================
1117
# Allowlist entries that cannot or should not be fixed; <= 3.12
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Meta(type): ...
2+
3+
4+
call = Meta.__dict__["__call__"]

stdlib/builtins.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ from typing import ( # noqa: Y022,UP035
4242
Any,
4343
BinaryIO,
4444
ClassVar,
45+
Final,
4546
Generic,
4647
Mapping,
4748
MutableMapping,
@@ -189,8 +190,9 @@ class type:
189190
__bases__: tuple[type, ...]
190191
@property
191192
def __basicsize__(self) -> int: ...
192-
@property
193-
def __dict__(self) -> types.MappingProxyType[str, Any]: ... # type: ignore[override]
193+
# type.__dict__ is read-only at runtime, but that can't be expressed currently.
194+
# See https://github.com/python/typeshed/issues/11033 for a discussion.
195+
__dict__: Final[types.MappingProxyType[str, Any]] # type: ignore[assignment]
194196
@property
195197
def __dictoffset__(self) -> int: ...
196198
@property
@@ -2058,6 +2060,10 @@ class BaseException:
20582060
def __new__(cls, *args: Any, **kwds: Any) -> Self: ...
20592061
def __setstate__(self, state: dict[str, Any] | None, /) -> None: ...
20602062
def with_traceback(self, tb: TracebackType | None, /) -> Self: ...
2063+
# Necessary for security-focused static analyzers (e.g, pysa)
2064+
# See https://github.com/python/typeshed/pull/14900
2065+
def __str__(self) -> str: ... # noqa: Y029
2066+
def __repr__(self) -> str: ... # noqa: Y029
20612067
if sys.version_info >= (3, 11):
20622068
# only present after add_note() is called
20632069
__notes__: list[str]

stdlib/cmath.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def exp(z: _C, /) -> complex: ...
2323
def isclose(a: _C, b: _C, *, rel_tol: SupportsFloat = 1e-09, abs_tol: SupportsFloat = 0.0) -> bool: ...
2424
def isinf(z: _C, /) -> bool: ...
2525
def isnan(z: _C, /) -> bool: ...
26-
def log(x: _C, base: _C = ..., /) -> complex: ...
26+
def log(z: _C, base: _C = ..., /) -> complex: ...
2727
def log10(z: _C, /) -> complex: ...
2828
def phase(z: _C, /) -> float: ...
2929
def polar(z: _C, /) -> tuple[float, float]: ...

0 commit comments

Comments
 (0)