Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b8d144d

Browse files
authored
Add 3.13 to our CI (#11926)
1 parent 347f8a9 commit b8d144d

8 files changed

Lines changed: 48 additions & 15 deletions

File tree

.github/workflows/tests.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ jobs:
7373
- run: uv pip install -r requirements-tests.txt --system
7474
- run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }}
7575

76+
# Run this as a separate job, as the other versions in the matrix are
77+
# (and should be) run *using* the Python version we're testing the stubs for,
78+
# but we can't install all our non-types dependencies on py313 yet
79+
mypy-313:
80+
name: Run mypy against the 3.13 stubs
81+
runs-on: ubuntu-latest
82+
strategy:
83+
matrix:
84+
platform: ["linux", "win32", "darwin"]
85+
fail-fast: false
86+
steps:
87+
- uses: actions/checkout@v4
88+
- uses: actions/setup-python@v5
89+
with:
90+
python-version: 3.12
91+
allow-prereleases: true
92+
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
93+
- run: uv pip install -r requirements-tests.txt --system
94+
- run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=3.13
95+
7696
regression-tests:
7797
name: Run mypy on the test cases
7898
runs-on: ubuntu-latest
@@ -93,7 +113,7 @@ jobs:
93113
strategy:
94114
matrix:
95115
python-platform: ["Linux", "Windows", "Darwin"]
96-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
116+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
97117
fail-fast: false
98118
steps:
99119
- uses: actions/checkout@v4
@@ -125,22 +145,22 @@ jobs:
125145
version: PATH
126146
python-platform: ${{ matrix.python-platform }}
127147
python-version: ${{ matrix.python-version }}
128-
annotate: ${{ matrix.python-version == '3.11' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
148+
annotate: ${{ matrix.python-version == '3.12' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
129149
- name: Run pyright with stricter settings on some of the stubs
130150
uses: jakebailey/pyright-action@v2
131151
with:
132152
version: PATH
133153
python-platform: ${{ matrix.python-platform }}
134154
python-version: ${{ matrix.python-version }}
135-
annotate: ${{ matrix.python-version == '3.11' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
155+
annotate: ${{ matrix.python-version == '3.12' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
136156
project: ./pyrightconfig.stricter.json
137157
- name: Run pyright on the test cases
138158
uses: jakebailey/pyright-action@v2
139159
with:
140160
version: PATH
141161
python-platform: ${{ matrix.python-platform }}
142162
python-version: ${{ matrix.python-version }}
143-
annotate: ${{ matrix.python-version == '3.11' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
163+
annotate: ${{ matrix.python-version == '3.12' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
144164
project: ./pyrightconfig.testcases.json
145165

146166
stub-uploader:

stdlib/logging/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ __all__ = [
5050
"makeLogRecord",
5151
"setLoggerClass",
5252
"shutdown",
53-
"warn",
5453
"warning",
5554
"getLogRecordFactory",
5655
"setLogRecordFactory",
5756
"lastResort",
5857
"raiseExceptions",
5958
]
6059

60+
if sys.version_info < (3, 13):
61+
__all__ += ["warn"]
6162
if sys.version_info >= (3, 11):
6263
__all__ += ["getLevelNamesMapping"]
6364
if sys.version_info >= (3, 12):

stubs/WebOb/webob/multidict.pyi

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import sys
12
from _typeshed import SupportsItems, SupportsKeysAndGetItem
23
from _typeshed.wsgi import WSGIEnvironment
3-
from cgi import FieldStorage
44
from collections.abc import Collection, Iterable, Iterator, MutableMapping
55
from typing import Any, Literal, TypeVar, overload
6-
from typing_extensions import Self
6+
from typing_extensions import Self, TypeAlias
7+
8+
if sys.version_info >= (3, 13):
9+
_FieldStorage: TypeAlias = Any
10+
else:
11+
from cgi import FieldStorage as _FieldStorage
712

813
_T = TypeVar("_T")
914
_KT = TypeVar("_KT")
@@ -19,7 +24,7 @@ class MultiDict(MutableMapping[_KT, _VT]):
1924
@classmethod
2025
def view_list(cls, lst: list[tuple[_KT, _VT]]) -> MultiDict[_KT, _VT]: ...
2126
@classmethod
22-
def from_fieldstorage(cls, fs: FieldStorage) -> MultiDict[str, str | FieldStorage]: ...
27+
def from_fieldstorage(cls, fs: _FieldStorage) -> MultiDict[str, str | _FieldStorage]: ...
2328
def __getitem__(self, key: _KT) -> _VT: ...
2429
def __setitem__(self, key: _KT, value: _VT) -> None: ...
2530
def add(self, key: _KT, value: _VT) -> None: ...

stubs/WebOb/webob/request.pyi

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import datetime
22
import io
3+
import sys
34
from _typeshed import ExcInfo, ReadableBuffer, SupportsItems, SupportsKeysAndGetItem, SupportsNoArgReadline, SupportsRead
45
from _typeshed.wsgi import WSGIApplication, WSGIEnvironment
5-
from cgi import FieldStorage
66
from collections.abc import Iterable, Mapping
77
from re import Pattern
88
from tempfile import _TemporaryFileWrapper
@@ -19,6 +19,11 @@ from webob.headers import EnvironHeaders
1919
from webob.multidict import GetDict, MultiDict, NestedMultiDict, NoVars
2020
from webob.response import Response, _HTTPHeader
2121

22+
if sys.version_info >= (3, 13):
23+
_FieldStorage: TypeAlias = Any
24+
else:
25+
from cgi import FieldStorage as _FieldStorage
26+
2227
_T = TypeVar("_T")
2328
_HTTPMethod: TypeAlias = Literal["GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"]
2429
_ListOrTuple: TypeAlias = list[_T] | tuple[_T, ...]
@@ -34,7 +39,9 @@ class _RequestCacheControlDict(TypedDict, total=False):
3439
no_transform: bool
3540
max_age: int
3641

37-
class _FieldStorageWithFile(FieldStorage):
42+
# On py313 this subclasses `Any`, hence the type: ignore.
43+
# This is needed for the regr_test.py script, which uses --disallow-subclassing-any
44+
class _FieldStorageWithFile(_FieldStorage): # type: ignore[misc]
3845
file: IO[bytes]
3946
filename: str
4047

@@ -244,4 +251,4 @@ class Transcoder:
244251
errors: str
245252
def __init__(self, charset: str, errors: str = "strict") -> None: ...
246253
def transcode_query(self, q: str) -> str: ...
247-
def transcode_fs(self, fs: FieldStorage, content_type: str) -> io.BytesIO: ...
254+
def transcode_fs(self, fs: _FieldStorage, content_type: str) -> io.BytesIO: ...

tests/mypy_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
print_error("Cannot import mypy. Did you install it?")
4949
sys.exit(1)
5050

51-
SUPPORTED_VERSIONS = ["3.12", "3.11", "3.10", "3.9", "3.8"]
51+
SUPPORTED_VERSIONS = ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]
5252
SUPPORTED_PLATFORMS = ("linux", "win32", "darwin")
5353
DIRECTORIES_TO_TEST = [Path("stdlib"), Path("stubs")]
5454

tests/regr_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
TYPESHED = "typeshed"
4141

4242
SUPPORTED_PLATFORMS = ["linux", "darwin", "win32"]
43-
SUPPORTED_VERSIONS = ["3.12", "3.11", "3.10", "3.9", "3.8"]
43+
SUPPORTED_VERSIONS = ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]
4444

4545

4646
def distribution_with_test_cases(distribution_name: str) -> DistributionTests:

tests/runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def main() -> None:
6262
parser.add_argument(
6363
"--python-version",
6464
default=_PYTHON_VERSION,
65-
choices=("3.8", "3.9", "3.10", "3.11", "3.12"),
65+
choices=("3.8", "3.9", "3.10", "3.11", "3.12", "3.13"),
6666
help="Target Python version for the test (default: %(default)s).",
6767
)
6868
parser.add_argument("path", help="Path of the stub to test in format <folder>/<stub>, from the root of the project.")

tests/typecheck_typeshed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
ReturnCode: TypeAlias = int
1414

1515
SUPPORTED_PLATFORMS = ("linux", "darwin", "win32")
16-
SUPPORTED_VERSIONS = ("3.12", "3.11", "3.10", "3.9")
16+
SUPPORTED_VERSIONS = ("3.13", "3.12", "3.11", "3.10", "3.9")
1717
LOWEST_SUPPORTED_VERSION = min(SUPPORTED_VERSIONS, key=lambda x: int(x.split(".")[1]))
1818
DIRECTORIES_TO_TEST = ("scripts", "tests")
1919
EMPTY: list[str] = []

0 commit comments

Comments
 (0)