Skip to content

Commit 8409335

Browse files
authored
Merge branch 'main' into mypy-2.0.0
2 parents f25b733 + 29bffca commit 8409335

41 files changed

Lines changed: 930 additions & 128 deletions

Some content is hidden

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

.github/workflows/daily.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
strategy:
3636
matrix:
3737
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
38-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
38+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
3939
exclude:
4040
# https://github.com/python/typeshed/issues/15694
4141
- os: "windows-latest"

.github/workflows/stubtest_stdlib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
strategy:
3232
matrix:
3333
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
34-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
34+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
3535
exclude:
3636
# https://github.com/python/typeshed/issues/15694
3737
- os: "windows-latest"

.github/workflows/tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
strategy:
4343
matrix:
4444
platform: ["linux", "win32", "darwin"]
45-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
45+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
4646
fail-fast: false
4747
steps:
4848
- uses: actions/checkout@v6
@@ -71,7 +71,9 @@ jobs:
7171
- uses: actions/checkout@v6
7272
- uses: actions/setup-python@v6
7373
with:
74-
python-version: "3.14"
74+
python-version: "3.15"
75+
allow-prereleases: true
76+
check-latest: true
7577
- uses: astral-sh/setup-uv@v7
7678
with:
7779
version-file: "requirements-tests.txt"
@@ -83,6 +85,8 @@ jobs:
8385
runs-on: ubuntu-latest
8486
strategy:
8587
matrix:
88+
# TODO: Add 3.15 once pyright CI can avoid installing third-party
89+
# runtime dependency stacks that do not support Python 3.15 yet.
8690
python-platform: ["Linux", "Windows", "Darwin"]
8791
python-version: ["3.11", "3.12", "3.13", "3.14"]
8892
fail-fast: false

CONTRIBUTING.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,6 @@ Features from the `typing` module that are not present in all
366366
supported Python versions must be imported from `typing_extensions`
367367
instead in typeshed stubs. This currently affects:
368368

369-
- `TypeAlias` (new in Python 3.10)
370-
- `Concatenate` (new in Python 3.10)
371-
- `ParamSpec` (new in Python 3.10)
372-
- `TypeGuard` (new in Python 3.10)
373369
- `Self` (new in Python 3.11)
374370
- `Never` (new in Python 3.11)
375371
- `LiteralString` (new in Python 3.11)

lib/ts_utils/py315.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Helpers for Python 3.15 test infrastructure."""
2+
3+
# These stubs require runtime dependencies that do not install cleanly on Python 3.15 yet.
4+
PY315_INCOMPATIBLE_RUNTIME_DEPENDENCIES = {
5+
# Depend on numpy, which does not provide Python 3.15 wheels yet.
6+
"JACK-Client",
7+
"geopandas",
8+
"hnswlib",
9+
"networkx",
10+
"pycocotools",
11+
"resampy",
12+
"shapely",
13+
"tensorflow",
14+
# Depends on referencing, which depends on rpds-py. rpds-py currently uses
15+
# PyO3, which rejects Python 3.15.
16+
"jsonschema",
17+
# Depends on matplotlib, which depends on contourpy. contourpy does not
18+
# provide Python 3.15 wheels yet.
19+
"seaborn",
20+
}

pyproject.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,6 @@ extend-safe-fixes = [
147147
"UP036", # Remove unnecessary `sys.version_info` blocks
148148
]
149149
ignore = [
150-
###
151-
# TODO: Disabled temporarily, until Python 3.9 support is fully removed in
152-
# May 2026.
153-
###
154-
"UP035", # import from typing
155-
"UP036", # Remove unnecessary `sys.version_info` blocks
156150
###
157151
# Rules that can conflict with the formatter (Black)
158152
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
@@ -238,6 +232,7 @@ ignore = [
238232
"D", # pydocstyle
239233
# See comment on black's force-exclude config above
240234
"E501", # Line too long
235+
"UP036", # Remove unnecessary `sys.version_info` blocks
241236
]
242237

243238
[tool.ruff.lint.pydocstyle]

requirements-tests.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ pyright==1.1.409
55

66
# Libraries used by our various scripts.
77
aiohttp==3.13.5
8-
grpcio-tools>=1.76.0 # For grpc_tools.protoc
9-
mypy-protobuf==5.0.0
8+
grpcio-tools>=1.76.0; python_version < "3.15" # For grpc_tools.protoc
9+
mypy-protobuf==5.0.0; python_version < "3.15"
1010
packaging==26.0
1111
pathspec>=1.1.1
1212
pre-commit
13-
# Required by create_baseline_stubs.py. Must match .pre-commit-config.yaml.
13+
# Required by create_baseline_stubs.py.
14+
# stubdefaulter depends on libcst, which does not yet install cleanly on Python 3.15.
1415
ruff==0.15.8
15-
stubdefaulter==0.1.0
16+
stubdefaulter==0.1.0; python_version < "3.15"
1617
termcolor>=2.3
1718
tomli==2.4.1; python_version < "3.11"
1819
tomlkit==0.14.0

scripts/sync_protobuf/_utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
import sys
55
from collections.abc import Iterable
66
from http.client import HTTPResponse
7+
from importlib.metadata import PackageNotFoundError, version
78
from pathlib import Path
89
from typing import TYPE_CHECKING
910
from urllib.request import urlopen
1011
from zipfile import ZipFile
1112

12-
from mypy_protobuf.main import ( # type: ignore[import-untyped] # pyright: ignore[reportMissingTypeStubs]
13-
__version__ as mypy_protobuf__version__,
14-
)
13+
try:
14+
_mypy_protobuf_version = version("mypy-protobuf")
15+
except PackageNotFoundError:
16+
_mypy_protobuf_version = "unavailable"
1517

1618
if TYPE_CHECKING:
1719
from _typeshed import StrOrBytesPath, StrPath
1820

19-
MYPY_PROTOBUF_VERSION = mypy_protobuf__version__
21+
MYPY_PROTOBUF_VERSION = _mypy_protobuf_version
2022

2123

2224
def download_file(url: str, destination: Path) -> None:

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist.
88
importlib.abc.PathEntryFinder.find_spec # Not defined on the actual class, but expected to exist.
9-
tkinter.simpledialog.[A-Z_]+
10-
tkinter.simpledialog.TclVersion
11-
tkinter.simpledialog.TkVersion
129
tarfile.TarInfo.__slots__ # it's a big dictionary at runtime and the dictionary values are a bit long
1310

1411

@@ -457,17 +454,6 @@ typing(_extensions)?\.TextIO\.newlines
457454
typing(_extensions)?\.IO\.__iter__
458455
typing(_extensions)?\.IO\.__next__
459456

460-
# typing.IO uses positional-or-keyword arguments, but in the stubs we prefer
461-
# to mark these as positional-only for compatibility with existing sub-classes.
462-
typing(_extensions)?\.BinaryIO\.write
463-
typing(_extensions)?\.IO\.read
464-
typing(_extensions)?\.IO\.readline
465-
typing(_extensions)?\.IO\.readlines
466-
typing(_extensions)?\.IO\.seek
467-
typing(_extensions)?\.IO\.truncate
468-
typing(_extensions)?\.IO\.write
469-
typing(_extensions)?\.IO\.writelines
470-
471457
types.MethodType.__closure__ # read-only but not actually a property; stubtest thinks it doesn't exist.
472458
types.MethodType.__code__ # read-only but not actually a property; stubtest thinks it doesn't exist.
473459
types.MethodType.__defaults__ # read-only but not actually a property; stubtest thinks it doesn't exist.
@@ -499,7 +485,3 @@ xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signatur
499485
# Iterable classes that don't define __iter__ at runtime (usually iterable via __getitem__)
500486
# These would ideally be special-cased by type checkers; see https://github.com/python/mypy/issues/2220
501487
xml.etree.ElementTree.Element.__iter__
502-
503-
# These three have a pos-or-keyword first parameter at runtime, but deliberately have a pos-only first parameter in the stub. #6812
504-
posixpath.join
505-
ntpath.join
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# ============================================
2+
# TODO: Allowlist entries that should be fixed
3+
# ============================================
4+
5+
_decimal.SPEC_VERSION
6+
_pyrepl.fancy_termios
7+
_pyrepl.unix_console
8+
_pyrepl.unix_eventqueue
9+
ctypes.c_double_complex._type_
10+
ctypes.c_float_complex._type_
11+
ctypes.c_longdouble_complex._type_
12+
decimal.SPEC_VERSION
13+
mmap.MS_ASYNC
14+
mmap.MS_INVALIDATE
15+
mmap.MS_SYNC
16+
mmap.mmap.madvise
17+
mmap.mmap.resize
18+
os.NODEV
19+
os.__all__
20+
posix.NODEV
21+
profiling.sampling.live_collector
22+
profiling.sampling.live_collector.collector
23+
profiling.sampling.live_collector.constants
24+
profiling.sampling.live_collector.display
25+
profiling.sampling.live_collector.trend_tracker
26+
profiling.sampling.live_collector.widgets
27+
readline.get_pre_input_hook
28+
resource.RLIM_SAVED_CUR
29+
resource.RLIM_SAVED_MAX

0 commit comments

Comments
 (0)