Skip to content

Commit 4e42234

Browse files
Merge branch 'main' into python315
2 parents e3a4134 + 4f63ff2 commit 4e42234

13 files changed

Lines changed: 84 additions & 57 deletions

File tree

.github/workflows/mypy_primer.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
25-
shard-index: [0, 1, 2, 3]
25+
shard-index: [0, 1, 2, 3, 4, 5]
2626
fail-fast: false
2727
steps:
2828
- uses: actions/checkout@v6
@@ -52,7 +52,7 @@ jobs:
5252
--new v${MYPY_VERSION} --old v${MYPY_VERSION} \
5353
--custom-typeshed-repo typeshed_to_test \
5454
--new-typeshed $GITHUB_SHA --old-typeshed upstream_main \
55-
--num-shards 4 --shard-index ${{ matrix.shard-index }} \
55+
--num-shards 6 --shard-index ${{ matrix.shard-index }} \
5656
--debug \
5757
--output concise \
5858
| tee diff_${{ matrix.shard-index }}.txt

requirements-tests.txt

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

66
# Libraries used by our various scripts.

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ turtledemo
1717
turtledemo\..+
1818

1919

20-
# ======================================================================
21-
# TODO: Module members that exist at runtime, but are missing from stubs
22-
# ======================================================================
23-
24-
tkinter.Misc.config
25-
26-
2720
# ======================================================================
2821
# Modules that exist at runtime, but are deliberately missing from stubs
2922
# ======================================================================

stdlib/selectors.pyi

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,26 @@ import sys
22
from _typeshed import FileDescriptor, FileDescriptorLike, Unused
33
from abc import ABCMeta, abstractmethod
44
from collections.abc import Mapping
5-
from typing import Any, Final, NamedTuple, TypeAlias
5+
from typing import Any, Final, NamedTuple
66
from typing_extensions import Self
77

8-
_EventMask: TypeAlias = int
9-
108
EVENT_READ: Final = 1
119
EVENT_WRITE: Final = 2
1210

1311
class SelectorKey(NamedTuple):
1412
fileobj: FileDescriptorLike
1513
fd: FileDescriptor
16-
events: _EventMask
14+
events: int
1715
data: Any
1816

1917
class BaseSelector(metaclass=ABCMeta):
2018
@abstractmethod
21-
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
19+
def register(self, fileobj: FileDescriptorLike, events: int, data: Any = None) -> SelectorKey: ...
2220
@abstractmethod
2321
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
24-
def modify(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
22+
def modify(self, fileobj: FileDescriptorLike, events: int, data: Any = None) -> SelectorKey: ...
2523
@abstractmethod
26-
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
24+
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ...
2725
def close(self) -> None: ...
2826
def get_key(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
2927
@abstractmethod
@@ -32,16 +30,16 @@ class BaseSelector(metaclass=ABCMeta):
3230
def __exit__(self, *args: Unused) -> None: ...
3331

3432
class _BaseSelectorImpl(BaseSelector, metaclass=ABCMeta):
35-
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
33+
def register(self, fileobj: FileDescriptorLike, events: int, data: Any = None) -> SelectorKey: ...
3634
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
37-
def modify(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
35+
def modify(self, fileobj: FileDescriptorLike, events: int, data: Any = None) -> SelectorKey: ...
3836
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
3937

4038
class SelectSelector(_BaseSelectorImpl):
41-
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
39+
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ...
4240

4341
class _PollLikeSelector(_BaseSelectorImpl):
44-
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
42+
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ...
4543

4644
if sys.platform != "win32":
4745
class PollSelector(_PollLikeSelector): ...
@@ -58,12 +56,12 @@ if sys.platform != "linux" and sys.platform != "darwin" and sys.platform != "win
5856
if sys.platform != "win32" and sys.platform != "linux":
5957
class KqueueSelector(_BaseSelectorImpl):
6058
def fileno(self) -> int: ...
61-
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
59+
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ...
6260

6361
# Not a real class at runtime, it is just a conditional alias to other real selectors.
6462
# The runtime logic is more fine-grained than a `sys.platform` check;
6563
# not really expressible in the stubs
6664
class DefaultSelector(_BaseSelectorImpl):
67-
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
65+
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ...
6866
if sys.platform != "win32":
6967
def fileno(self) -> int: ...

stdlib/string/templatelib.pyi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
from collections.abc import Iterator
22
from types import GenericAlias
3-
from typing import Any, Literal, TypeVar, final, overload
3+
from typing import Any, Generic, Literal, TypeVar, final, overload
44

55
_T = TypeVar("_T")
66

77
@final
88
class Template: # TODO: consider making `Template` generic on `TypeVarTuple`
99
strings: tuple[str, ...]
10-
interpolations: tuple[Interpolation, ...]
10+
interpolations: tuple[Interpolation[Any], ...]
1111

12-
def __new__(cls, *args: str | Interpolation) -> Template: ...
13-
def __iter__(self) -> Iterator[str | Interpolation]: ...
12+
def __new__(cls, *args: str | Interpolation[Any]) -> Template: ...
13+
def __iter__(self) -> Iterator[str | Interpolation[Any]]: ...
1414
def __add__(self, other: Template, /) -> Template: ...
1515
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
1616
@property
1717
def values(self) -> tuple[Any, ...]: ... # Tuple of interpolation values, which can have any type
1818

1919
@final
20-
class Interpolation:
21-
value: Any # TODO: consider making `Interpolation` generic in runtime
20+
class Interpolation(Generic[_T]):
21+
value: _T
2222
expression: str
2323
conversion: Literal["a", "r", "s"] | None
2424
format_spec: str
2525

2626
__match_args__ = ("value", "expression", "conversion", "format_spec")
2727

2828
def __new__(
29-
cls, value: Any, expression: str = "", conversion: Literal["a", "r", "s"] | None = None, format_spec: str = ""
30-
) -> Interpolation: ...
29+
cls, value: _T, expression: str = "", conversion: Literal["a", "r", "s"] | None = None, format_spec: str = ""
30+
) -> Interpolation[_T]: ...
3131
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
3232

3333
@overload

stdlib/tkinter/__init__.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,7 @@ class Misc:
679679
def __getitem__(self, key: str) -> Any: ...
680680
def cget(self, key: str) -> Any: ...
681681
def configure(self, cnf: Any = None) -> Any: ...
682-
# TODO: config is an alias of configure, but adding that here creates
683-
# conflict with the type of config in the subclasses. See #13149
682+
config = configure
684683

685684
class CallWrapper:
686685
func: Incomplete

stubs/gevent/gevent/selectors.pyi

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
from _typeshed import FileDescriptorLike
22
from collections.abc import Mapping
33
from selectors import BaseSelector, SelectorKey
4-
from typing import Any, TypeAlias
4+
from typing import Any
55

66
from gevent._util import Lazy
77
from gevent.hub import Hub
88

99
__all__ = ["DefaultSelector", "GeventSelector"]
1010

11-
_EventMask: TypeAlias = int
12-
1311
# technically this derives from _BaseSelectorImpl, which does not have type annotations
1412
# but in terms of type checking the only difference is, that we need to add get_map since
1513
# GeventSelector does not override it
1614
class GeventSelector(BaseSelector):
1715
def __init__(self, hub: Hub | None = None) -> None: ...
1816
@Lazy
1917
def hub(self) -> Hub: ...
20-
def register(self, fileobj: FileDescriptorLike, events: _EventMask, data: Any = None) -> SelectorKey: ...
18+
def register(self, fileobj: FileDescriptorLike, events: int, data: Any = None) -> SelectorKey: ...
2119
def unregister(self, fileobj: FileDescriptorLike) -> SelectorKey: ...
22-
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, _EventMask]]: ...
20+
def select(self, timeout: float | None = None) -> list[tuple[SelectorKey, int]]: ...
2321
def close(self) -> None: ...
2422
def get_map(self) -> Mapping[FileDescriptorLike, SelectorKey]: ...
2523

stubs/jwcrypto/jwcrypto/jwk.pyi

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,23 @@ class InvalidJWKValue(JWException): ...
104104

105105
class JWK(dict[str, Any]):
106106
unsafe_skip_rsa_key_validation: bool
107+
@overload
108+
def __init__(
109+
self,
110+
*,
111+
generate: Literal["RSA"],
112+
public_exponent: int | None = None,
113+
size: int | None = None,
114+
kid: str | None = None,
115+
alg: str | None = None,
116+
use: _JWKUseSupported | None = None,
117+
key_ops: list[_JWKOperationSupported] | None = None,
118+
) -> None: ...
119+
@overload
120+
def __init__(self, *, generate: Literal["oct", "EC", "OKP"], **kwargs) -> None: ...
121+
@overload
107122
def __init__(self, **kwargs) -> None: ...
108-
# `kty` and the other keyword arguments are passed as `params` to the called generator
109-
# function. The possible arguments depend on the value of `kty`.
110-
# TODO: Add overloads for the individual `kty` values.
123+
# TODO: __init__ may not be typed adequately because keyword arguments depend on the value of generate
111124
@classmethod
112125
@overload
113126
def generate(
@@ -230,6 +243,7 @@ class JWK(dict[str, Any]):
230243
@classmethod
231244
def from_password(cls, password: str) -> Self: ...
232245
def setdefault(self, key: str, default: _T | None = None) -> _T: ...
246+
def __hash__(self) -> int: ... # type: ignore[override]
233247

234248
class JWKSet(dict[Literal["keys"], set[JWK]]):
235249
@overload
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
from _typeshed import Incomplete
2-
31
from networkx.classes.graph import Graph, _Node
42
from networkx.utils.backends import _dispatchable
53

64
__all__ = ["communicability", "communicability_exp"]
75

86
@_dispatchable
9-
def communicability(G: Graph[_Node]) -> dict[dict[Incomplete, Incomplete], dict[Incomplete, float]]: ...
7+
def communicability(G: Graph[_Node]) -> dict[_Node, dict[_Node, float]]: ...
108
@_dispatchable
11-
def communicability_exp(G: Graph[_Node]) -> dict[dict[Incomplete, Incomplete], dict[Incomplete, float]]: ...
9+
def communicability_exp(G: Graph[_Node]) -> dict[_Node, dict[_Node, float]]: ...

stubs/requests/METADATA.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
# requires a version of urllib3 with a py.typed file
12
version = "~=2.33.0"
23
upstream-repository = "https://github.com/psf/requests"
3-
# requires a version of urllib3 with a py.typed file
44
dependencies = ["urllib3>=2"]
55
extra-description = """\
66
Note: `types-requests` has required `urllib3>=2` since v2.31.0.7. \
77
If you need to install `types-requests` into an environment \
88
that must also have `urllib3<2` installed into it, \
99
you will have to use `types-requests<2.31.0.7`.\
1010
"""
11+
obsolete-since = "2.34.0" # Released on 2026-05-11
1112

1213
[tool.stubtest]
1314
extras = ["socks"]

0 commit comments

Comments
 (0)