Skip to content

Commit 29fe2af

Browse files
srittaumingyu.park
authored andcommitted
Support Python 3.14 (python#13957)
1 parent 571167c commit 29fe2af

File tree

21 files changed

+1082
-34
lines changed

21 files changed

+1082
-34
lines changed

.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.9", "3.10", "3.11", "3.12", "3.13"]
38+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"]
3939
fail-fast: false
4040

4141
steps:

.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.9", "3.10", "3.11", "3.12", "3.13"]
34+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"]
3535
fail-fast: false
3636

3737
steps:

.github/workflows/tests.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ jobs:
6161
strategy:
6262
matrix:
6363
platform: ["linux", "win32", "darwin"]
64-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
64+
# TODO (2025-05-10) "3.13.2" should be "3.14-dev", see below.
65+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.13.2"]
6566
fail-fast: false
6667
steps:
6768
- uses: actions/checkout@v4
@@ -77,10 +78,17 @@ jobs:
7778
printf "Installing APT packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n"
7879
sudo apt-get install -qy $DEPENDENCIES
7980
fi
80-
- run: |
81-
# python-version can sometimes be pinned to a specific version or to "-dev", but
82-
# mypy understands only X.Y version numbers.
83-
MYPY_PY_VERSION=$(echo ${{ matrix.python-version }} | cut -d - -f 1 | cut -d . -f 1-2)
81+
- name: Run mypy_test.py
82+
run: |
83+
# TODO: (2025-05-10) This is a bad hack to work around mypy crashing
84+
# when running on Python 3.14. See https://github.com/python/mypy/pull/19020.
85+
if [[ "${{ matrix.python-version }}" == "3.13.2" ]]; then
86+
MYPY_PY_VERSION="3.14"
87+
else
88+
# python-version can sometimes be pinned to a specific version or to "-dev", but
89+
# mypy understands only X.Y version numbers.
90+
MYPY_PY_VERSION=$(echo ${{ matrix.python-version }} | cut -d - -f 1 | cut -d . -f 1-2)
91+
fi
8492
python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${MYPY_PY_VERSION}
8593
8694
regression-tests:
@@ -103,7 +111,7 @@ jobs:
103111
strategy:
104112
matrix:
105113
python-platform: ["Linux", "Windows", "Darwin"]
106-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
114+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
107115
fail-fast: false
108116
steps:
109117
- uses: actions/checkout@v4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ the project the stubs are for, but instead report them here to typeshed.**
2121
Further documentation on stub files, typeshed, and Python's typing system in
2222
general, can also be found at https://typing.readthedocs.io/en/latest/.
2323

24-
Typeshed supports Python versions 3.9 to 3.13.
24+
Typeshed supports Python versions 3.9 to 3.14.
2525

2626
## Using
2727

requirements-tests.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@ pyright==1.1.400
66
pytype==2024.10.11; platform_system != "Windows" and python_version >= "3.10" and python_version < "3.13"
77

88
# Libraries used by our various scripts.
9-
aiohttp==3.11.15
10-
grpcio-tools>=1.66.2 # For grpc_tools.protoc
9+
# TODO (2025-05-09): Installing this on Python 3.14 on Windows fails at
10+
# the moment.
11+
aiohttp==3.11.15; python_version < "3.14"
12+
# TODO (2025-05-09): No wheels exist for Python 3.14 yet, slowing down CI
13+
# considerably and prone to fail.
14+
grpcio-tools>=1.66.2; python_version < "3.14" # For grpc_tools.protoc
1115
mypy-protobuf==3.6.0
1216
packaging==24.2
1317
pathspec>=0.11.1
1418
pre-commit
1519
# Required by create_baseline_stubs.py. Must match .pre-commit-config.yaml.
1620
ruff==0.11.4
17-
stubdefaulter==0.1.0
21+
# TODO (2025-05-07): Dependency libcst doesn't support Python 3.14 yet.
22+
stubdefaulter==0.1.0; python_version < "3.14"
1823
termcolor>=2.3
1924
tomli==2.2.1
2025
tomlkit==0.13.2

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,6 @@ _collections_abc.AsyncGenerator.__anext__
183183
_collections_abc.AsyncGenerator.aclose
184184
_collections_abc.AsyncIterator.__anext__
185185

186-
# Pretend typing.ByteString is a Union, to better match its documented semantics.
187-
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
188-
# because it's not an ABC that makes any sense and was deprecated in 3.12
189-
_collections_abc.ByteString
190-
191186
_collections_abc.Callable # Typing-related weirdness
192187
_collections_abc.Mapping.get # Adding None to the Union messed up mypy
193188
_collections_abc.Sequence.index # Supporting None in end is not mandatory
@@ -215,12 +210,7 @@ _?ast.stmt.__init__
215210

216211
_ast.ImportFrom.level # None on the class, but never None on instances
217212

218-
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
219-
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
220213
ast.ImportFrom.level # None on the class, but never None on instances
221-
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
222-
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
223-
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
224214
ast.NodeVisitor.visit_\w+ # Methods are discovered dynamically, see #3796
225215
_?asyncio.Future.__init__ # Usually initialized from c object
226216
asyncio.futures.Future.__init__ # Usually initialized from c object
@@ -312,7 +302,6 @@ enum.auto.__xor__ # enum.auto is magic, see comments
312302
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
313303
functools.cached_property.__set__ # doesn't exist, but cached_property is settable by another mechanism
314304

315-
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
316305
hmac.new # Raises TypeError if optional argument digestmod is not provided
317306
http.HTTPStatus.description # set in __new__; work-around for enum wierdness
318307
http.HTTPStatus.phrase # set in __new__; work-around for enum wierdness
@@ -325,7 +314,6 @@ importlib._bootstrap_external.FileLoader.get_resource_reader
325314
importlib._bootstrap_external.FileLoader.load_module
326315
importlib.abc.FileLoader.get_filename
327316
importlib.abc.FileLoader.load_module
328-
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
329317
importlib.machinery.ExtensionFileLoader.get_filename
330318

331319
# We can't distinguish not having a default value from having a default value of inspect.Parameter.empty
@@ -472,7 +460,6 @@ typing_extensions\.TypeVar.*
472460
typing_extensions\._SpecialForm.*
473461

474462
# Special primitives
475-
typing\.ByteString
476463
typing(_extensions)?\.AbstractSet
477464
typing(_extensions)?\.AsyncGenerator
478465
typing(_extensions)?\.AsyncIterable
@@ -527,10 +514,6 @@ typing(_extensions)?\.(Async)?ContextManager
527514
typing(_extensions)?\.IO\.__iter__
528515
typing(_extensions)?\.IO\.__next__
529516

530-
# Will always raise. Not included to avoid type checkers inferring that
531-
# TypeAliasType instances are callable.
532-
typing_extensions.TypeAliasType.__call__
533-
534517
types.MethodType.__closure__ # read-only but not actually a property; stubtest thinks it doesn't exist.
535518
types.MethodType.__code__ # read-only but not actually a property; stubtest thinks it doesn't exist.
536519
types.MethodType.__defaults__ # read-only but not actually a property; stubtest thinks it doesn't exist.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# ====================================================================
2+
# TODO: New errors in Python 3.14 that need to be fixed or moved below
3+
# ====================================================================
4+
5+
_curses.assume_default_colors
6+
_posixsubprocess.fork_exec
7+
asyncio.tools
8+
asyncio.unix_events.__all__
9+
asyncio.unix_events.DefaultEventLoopPolicy
10+
asyncio.unix_events._DefaultEventLoopPolicy
11+
ctypes.c_double_complex._type_
12+
ctypes.c_float_complex._type_
13+
ctypes.c_longdouble_complex._type_
14+
multiprocessing.popen_fork.Popen.interrupt
15+
multiprocessing.reduction.ACKNOWLEDGE
16+
posix.readinto
17+
18+
19+
# =======
20+
# >= 3.13
21+
# =======
22+
23+
(mmap.MAP_32BIT)? # Exists locally on MacOS but not on GitHub
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# ====================================================================
2+
# TODO: New errors in Python 3.14 that need to be fixed or moved below
3+
# ====================================================================
4+
5+
_curses.assume_default_colors
6+
_posixsubprocess.fork_exec
7+
_socket.CAN_RAW_ERR_FILTER
8+
_socket.IPV6_RECVERR
9+
_socket.IP_FREEBIND
10+
_socket.IP_RECVERR
11+
_socket.IP_RECVORIGDSTADDR
12+
_socket.SO_ORIGINAL_DST
13+
_socket.VMADDR_CID_LOCAL
14+
asyncio.tools
15+
asyncio.unix_events.__all__
16+
asyncio.unix_events.DefaultEventLoopPolicy
17+
asyncio.unix_events._DefaultEventLoopPolicy
18+
ctypes.c_double_complex._type_
19+
ctypes.c_float_complex._type_
20+
ctypes.c_longdouble_complex._type_
21+
errno.EHWPOISON
22+
multiprocessing.popen_fork.Popen.interrupt
23+
multiprocessing.reduction.ACKNOWLEDGE
24+
os.SCHED_DEADLINE
25+
os.SCHED_NORMAL
26+
posix.SCHED_DEADLINE
27+
posix.SCHED_NORMAL
28+
posix.readinto
29+
select.EPOLLWAKEUP
30+
socket.CAN_RAW_ERR_FILTER
31+
socket.IPV6_RECVERR
32+
socket.IP_FREEBIND
33+
socket.IP_RECVERR
34+
socket.IP_RECVORIGDSTADDR
35+
socket.SO_ORIGINAL_DST
36+
socket.VMADDR_CID_LOCAL

stdlib/@tests/stubtest_allowlists/py310.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,32 @@ tkinter.tix.TclVersion
150150
tkinter.tix.TkVersion
151151

152152

153+
# =======
154+
# <= 3.13
155+
# =======
156+
157+
# Pretend typing.ByteString is a Union, to better match its documented semantics.
158+
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
159+
# because it's not an ABC that makes any sense and was deprecated in 3.12
160+
_collections_abc.ByteString
161+
162+
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
163+
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
164+
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
165+
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
166+
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
167+
168+
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
169+
170+
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
171+
172+
typing\.ByteString
173+
174+
# Will always raise. Not included to avoid type checkers inferring that
175+
# TypeAliasType instances are callable.
176+
typing_extensions.TypeAliasType.__call__
177+
178+
153179
# =============================================================
154180
# Allowlist entries that cannot or should not be fixed; >= 3.10
155181
# =============================================================

stdlib/@tests/stubtest_allowlists/py311.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,32 @@ tkinter.tix.TclVersion
117117
tkinter.tix.TkVersion
118118

119119

120+
# =======
121+
# <= 3.13
122+
# =======
123+
124+
# Pretend typing.ByteString is a Union, to better match its documented semantics.
125+
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
126+
# because it's not an ABC that makes any sense and was deprecated in 3.12
127+
_collections_abc.ByteString
128+
129+
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
130+
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
131+
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
132+
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
133+
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
134+
135+
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
136+
137+
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
138+
139+
typing\.ByteString
140+
141+
# Will always raise. Not included to avoid type checkers inferring that
142+
# TypeAliasType instances are callable.
143+
typing_extensions.TypeAliasType.__call__
144+
145+
120146
# =============================================================
121147
# Allowlist entries that cannot or should not be fixed; >= 3.11
122148
# =============================================================

stdlib/@tests/stubtest_allowlists/py312.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,32 @@ tkinter.tix.TclVersion
100100
tkinter.tix.TkVersion
101101

102102

103+
# =======
104+
# <= 3.13
105+
# =======
106+
107+
# Pretend typing.ByteString is a Union, to better match its documented semantics.
108+
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
109+
# because it's not an ABC that makes any sense and was deprecated in 3.12
110+
_collections_abc.ByteString
111+
112+
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
113+
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
114+
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
115+
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
116+
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
117+
118+
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
119+
120+
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
121+
122+
typing\.ByteString
123+
124+
# Will always raise. Not included to avoid type checkers inferring that
125+
# TypeAliasType instances are callable.
126+
typing_extensions.TypeAliasType.__call__
127+
128+
103129
# =============================================================
104130
# Allowlist entries that cannot or should not be fixed; >= 3.12
105131
# =============================================================

stdlib/@tests/stubtest_allowlists/py313.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,32 @@ typing(_extensions)?\.IO\.write
6161
typing(_extensions)?\.IO\.writelines
6262

6363

64+
# =======
65+
# <= 3.13
66+
# =======
67+
68+
# Pretend typing.ByteString is a Union, to better match its documented semantics.
69+
# As a side effect, this changes the definition of collections.abc.ByteString, which is okay,
70+
# because it's not an ABC that makes any sense and was deprecated in 3.12
71+
_collections_abc.ByteString
72+
73+
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
74+
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
75+
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
76+
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
77+
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
78+
79+
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
80+
81+
importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments.
82+
83+
typing\.ByteString
84+
85+
# Will always raise. Not included to avoid type checkers inferring that
86+
# TypeAliasType instances are callable.
87+
typing_extensions.TypeAliasType.__call__
88+
89+
6490
# =============================================================
6591
# Allowlist entries that cannot or should not be fixed; >= 3.13
6692
# =============================================================

0 commit comments

Comments
 (0)