Skip to content

Commit

Permalink
Add 3.13 to our CI (#11926)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed May 19, 2024
1 parent 347f8a9 commit b8d144d
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 15 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ jobs:
- run: uv pip install -r requirements-tests.txt --system
- run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }}

# Run this as a separate job, as the other versions in the matrix are
# (and should be) run *using* the Python version we're testing the stubs for,
# but we can't install all our non-types dependencies on py313 yet
mypy-313:
name: Run mypy against the 3.13 stubs
runs-on: ubuntu-latest
strategy:
matrix:
platform: ["linux", "win32", "darwin"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
allow-prereleases: true
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
- run: uv pip install -r requirements-tests.txt --system
- run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=3.13

regression-tests:
name: Run mypy on the test cases
runs-on: ubuntu-latest
Expand All @@ -93,7 +113,7 @@ jobs:
strategy:
matrix:
python-platform: ["Linux", "Windows", "Darwin"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -125,22 +145,22 @@ jobs:
version: PATH
python-platform: ${{ matrix.python-platform }}
python-version: ${{ matrix.python-version }}
annotate: ${{ matrix.python-version == '3.11' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
annotate: ${{ matrix.python-version == '3.12' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
- name: Run pyright with stricter settings on some of the stubs
uses: jakebailey/pyright-action@v2
with:
version: PATH
python-platform: ${{ matrix.python-platform }}
python-version: ${{ matrix.python-version }}
annotate: ${{ matrix.python-version == '3.11' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
annotate: ${{ matrix.python-version == '3.12' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
project: ./pyrightconfig.stricter.json
- name: Run pyright on the test cases
uses: jakebailey/pyright-action@v2
with:
version: PATH
python-platform: ${{ matrix.python-platform }}
python-version: ${{ matrix.python-version }}
annotate: ${{ matrix.python-version == '3.11' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
annotate: ${{ matrix.python-version == '3.12' && matrix.python-platform == 'Linux' }} # Having each job create the same comment is too noisy.
project: ./pyrightconfig.testcases.json

stub-uploader:
Expand Down
3 changes: 2 additions & 1 deletion stdlib/logging/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ __all__ = [
"makeLogRecord",
"setLoggerClass",
"shutdown",
"warn",
"warning",
"getLogRecordFactory",
"setLogRecordFactory",
"lastResort",
"raiseExceptions",
]

if sys.version_info < (3, 13):
__all__ += ["warn"]
if sys.version_info >= (3, 11):
__all__ += ["getLevelNamesMapping"]
if sys.version_info >= (3, 12):
Expand Down
11 changes: 8 additions & 3 deletions stubs/WebOb/webob/multidict.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import sys
from _typeshed import SupportsItems, SupportsKeysAndGetItem
from _typeshed.wsgi import WSGIEnvironment
from cgi import FieldStorage
from collections.abc import Collection, Iterable, Iterator, MutableMapping
from typing import Any, Literal, TypeVar, overload
from typing_extensions import Self
from typing_extensions import Self, TypeAlias

if sys.version_info >= (3, 13):
_FieldStorage: TypeAlias = Any
else:
from cgi import FieldStorage as _FieldStorage

_T = TypeVar("_T")
_KT = TypeVar("_KT")
Expand All @@ -19,7 +24,7 @@ class MultiDict(MutableMapping[_KT, _VT]):
@classmethod
def view_list(cls, lst: list[tuple[_KT, _VT]]) -> MultiDict[_KT, _VT]: ...
@classmethod
def from_fieldstorage(cls, fs: FieldStorage) -> MultiDict[str, str | FieldStorage]: ...
def from_fieldstorage(cls, fs: _FieldStorage) -> MultiDict[str, str | _FieldStorage]: ...
def __getitem__(self, key: _KT) -> _VT: ...
def __setitem__(self, key: _KT, value: _VT) -> None: ...
def add(self, key: _KT, value: _VT) -> None: ...
Expand Down
13 changes: 10 additions & 3 deletions stubs/WebOb/webob/request.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import datetime
import io
import sys
from _typeshed import ExcInfo, ReadableBuffer, SupportsItems, SupportsKeysAndGetItem, SupportsNoArgReadline, SupportsRead
from _typeshed.wsgi import WSGIApplication, WSGIEnvironment
from cgi import FieldStorage
from collections.abc import Iterable, Mapping
from re import Pattern
from tempfile import _TemporaryFileWrapper
Expand All @@ -19,6 +19,11 @@ from webob.headers import EnvironHeaders
from webob.multidict import GetDict, MultiDict, NestedMultiDict, NoVars
from webob.response import Response, _HTTPHeader

if sys.version_info >= (3, 13):
_FieldStorage: TypeAlias = Any
else:
from cgi import FieldStorage as _FieldStorage

_T = TypeVar("_T")
_HTTPMethod: TypeAlias = Literal["GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"]
_ListOrTuple: TypeAlias = list[_T] | tuple[_T, ...]
Expand All @@ -34,7 +39,9 @@ class _RequestCacheControlDict(TypedDict, total=False):
no_transform: bool
max_age: int

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

Expand Down Expand Up @@ -244,4 +251,4 @@ class Transcoder:
errors: str
def __init__(self, charset: str, errors: str = "strict") -> None: ...
def transcode_query(self, q: str) -> str: ...
def transcode_fs(self, fs: FieldStorage, content_type: str) -> io.BytesIO: ...
def transcode_fs(self, fs: _FieldStorage, content_type: str) -> io.BytesIO: ...
2 changes: 1 addition & 1 deletion tests/mypy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
print_error("Cannot import mypy. Did you install it?")
sys.exit(1)

SUPPORTED_VERSIONS = ["3.12", "3.11", "3.10", "3.9", "3.8"]
SUPPORTED_VERSIONS = ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]
SUPPORTED_PLATFORMS = ("linux", "win32", "darwin")
DIRECTORIES_TO_TEST = [Path("stdlib"), Path("stubs")]

Expand Down
2 changes: 1 addition & 1 deletion tests/regr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
TYPESHED = "typeshed"

SUPPORTED_PLATFORMS = ["linux", "darwin", "win32"]
SUPPORTED_VERSIONS = ["3.12", "3.11", "3.10", "3.9", "3.8"]
SUPPORTED_VERSIONS = ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]


def distribution_with_test_cases(distribution_name: str) -> DistributionTests:
Expand Down
2 changes: 1 addition & 1 deletion tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def main() -> None:
parser.add_argument(
"--python-version",
default=_PYTHON_VERSION,
choices=("3.8", "3.9", "3.10", "3.11", "3.12"),
choices=("3.8", "3.9", "3.10", "3.11", "3.12", "3.13"),
help="Target Python version for the test (default: %(default)s).",
)
parser.add_argument("path", help="Path of the stub to test in format <folder>/<stub>, from the root of the project.")
Expand Down
2 changes: 1 addition & 1 deletion tests/typecheck_typeshed.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ReturnCode: TypeAlias = int

SUPPORTED_PLATFORMS = ("linux", "darwin", "win32")
SUPPORTED_VERSIONS = ("3.12", "3.11", "3.10", "3.9")
SUPPORTED_VERSIONS = ("3.13", "3.12", "3.11", "3.10", "3.9")
LOWEST_SUPPORTED_VERSION = min(SUPPORTED_VERSIONS, key=lambda x: int(x.split(".")[1]))
DIRECTORIES_TO_TEST = ("scripts", "tests")
EMPTY: list[str] = []
Expand Down

0 comments on commit b8d144d

Please sign in to comment.