Skip to content

Commit f3de16a

Browse files
authored
Add support for Python 3.13 (#640)
* fix: rename deprecated typing._collect_parameters (Python 3.13) * chore: update ci actions * chore: add Python 3.13 classifier * chore: update cython to 3.0.11 * fix: make scripts/cythonize.sh executable * fix: add setuptools as build dependency for 3.12+ * chore: update build-system * chore: update pycln to v2.4.0 * chore: update test requirements to avoid DeprecationWarnings * chore: update pydantic test requirements to avoid DeprecationWarning * chore: update codecov-action to v4
1 parent d48cc01 commit f3de16a

File tree

10 files changed

+55
-43
lines changed

10 files changed

+55
-43
lines changed

.github/workflows/cd.yml

+15-9
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ jobs:
1212
- uses: actions/checkout@v4
1313
- run: scripts/cythonize.sh
1414
- run: pipx run build --sdist
15-
- uses: actions/upload-artifact@v3
15+
- uses: actions/upload-artifact@v4
1616
with:
17-
name: dist
17+
name: dist-sdist
1818
path: dist/*.tar.gz
1919
build_pure_wheel:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
2323
- run: scripts/cythonize.sh
2424
- run: NO_EXTENSION=1 pipx run build
25-
- uses: actions/upload-artifact@v3
25+
- uses: actions/upload-artifact@v4
2626
with:
27-
name: dist
27+
name: dist-wheel
2828
path: dist/*.whl
2929
build_wheels:
3030
name: Wheel on ${{ matrix.os }}
@@ -34,9 +34,14 @@ jobs:
3434
os: [ubuntu-latest, macos-latest, windows-latest]
3535
steps:
3636
- uses: actions/checkout@v4
37+
- name: Set up Python 3.12 (MacOS)
38+
if: matrix.os == 'macos-latest'
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.12"
3742
- run: scripts/cythonize.sh
3843
- run: scripts/generate_tests_from_examples.py
39-
- uses: pypa/cibuildwheel@v2.16.2
44+
- uses: pypa/cibuildwheel@v2.21.1
4045
env:
4146
CIBW_SKIP: pp*
4247
CIBW_TEST_COMMAND: pytest {project}/tests
@@ -45,19 +50,20 @@ jobs:
4550
CIBW_BEFORE_TEST: pip install -r tests/requirements.txt
4651
# TODO is skipping still necessary?
4752
CIBW_TEST_SKIP: "*universal2:arm64"
48-
- uses: actions/upload-artifact@v3
53+
- uses: actions/upload-artifact@v4
4954
with:
50-
name: dist
55+
name: dist-${{ matrix.os }}
5156
path: wheelhouse/*.whl
5257
publish:
5358
needs: [build_sdist, build_wheels]
5459
runs-on: ubuntu-latest
5560
if: github.event_name == 'release' && github.event.action == 'published'
5661
steps:
57-
- uses: actions/download-artifact@v3
62+
- uses: actions/download-artifact@v4
5863
with:
59-
name: dist
6064
path: dist
65+
pattern: dist-*
66+
merge-multiple: true
6167
- uses: pypa/gh-action-pypi-publish@v1.8.10
6268
with:
6369
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9', 'pypy-3.10']
27+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13-dev', 'pypy-3.9', 'pypy-3.10']
2828
include:
2929
- python-version: '3.12'
3030
pytest-args: --cov=apischema --cov-branch --cov-report=xml --cov-report=html
3131
steps:
32-
- uses: actions/cache@v3.3.2
32+
- uses: actions/cache@v4
3333
with:
3434
path: ~/.cache/pip
3535
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements.txt') }}
3636
restore-keys: |
3737
${{ runner.os }}-pip-
3838
- uses: actions/checkout@v4
3939
- name: Set up Python ${{ matrix.python-version }}
40-
uses: actions/setup-python@v4
40+
uses: actions/setup-python@v5
4141
with:
4242
python-version: ${{ matrix.python-version }}
4343
- name: Install requirements
@@ -46,10 +46,10 @@ jobs:
4646
run: scripts/generate_tests_from_examples.py
4747
- name: Run tests
4848
run: pytest tests ${{ matrix.pytest-args }}
49-
- uses: codecov/codecov-action@v3
49+
- uses: codecov/codecov-action@v4
5050
# https://github.saobby.my.eu.orgmunity/t/run-step-if-file-exists/16445/3
5151
if: hashFiles('coverage.xml') != ''
52-
- uses: actions/upload-artifact@v3
52+
- uses: actions/upload-artifact@v4
5353
if: hashFiles('coverage.xml') != ''
5454
with:
5555
name: coverage

.github/workflows/doc.yml

+16-17
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ jobs:
2626
run_benchmark:
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/cache@v3.3.2
29+
- uses: actions/cache@v4
3030
with:
3131
path: ~/.cache/pip
3232
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements.txt') }}
3333
restore-keys: |
3434
${{ runner.os }}-pip-
3535
- uses: actions/checkout@v4
36-
- uses: actions/setup-python@v4
36+
- uses: actions/setup-python@v5
3737
with:
3838
python-version: '3.12'
3939
- name: Cythonize
@@ -44,49 +44,49 @@ jobs:
4444
run: pip install -r benchmark/requirements.txt
4545
- name: Run benchmark
4646
run: python benchmark/main.py
47-
- uses: actions/upload-artifact@v3
47+
- uses: actions/upload-artifact@v4
4848
with:
4949
name: benchmark_table
5050
path: examples/benchmark_table.md
51-
- uses: actions/upload-artifact@v3
51+
- uses: actions/upload-artifact@v4
5252
with:
5353
name: benchmark_chart_light
5454
path: docs/benchmark_chart_light.svg
55-
- uses: actions/upload-artifact@v3
55+
- uses: actions/upload-artifact@v4
5656
with:
5757
name: benchmark_chart_dark
5858
path: docs/benchmark_chart_dark.svg
5959
upload_doc:
6060
needs: [run_benchmark]
6161
runs-on: ubuntu-latest
6262
steps:
63-
- uses: actions/cache@v3.3.2
63+
- uses: actions/cache@v4
6464
with:
6565
path: ~/.cache/pip
6666
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements.txt') }}
6767
restore-keys: |
6868
${{ runner.os }}-pip-
6969
- uses: actions/checkout@v4
70-
- uses: actions/setup-python@v4
70+
- uses: actions/setup-python@v5
7171
with:
7272
python-version: '3.12'
73-
- uses: actions/download-artifact@v3
73+
- uses: actions/download-artifact@v4
7474
with:
7575
name: benchmark_table
7676
path: examples
77-
- uses: actions/download-artifact@v3
77+
- uses: actions/download-artifact@v4
7878
with:
7979
name: benchmark_chart_light
8080
path: docs
81-
- uses: actions/download-artifact@v3
81+
- uses: actions/download-artifact@v4
8282
with:
8383
name: benchmark_chart_dark
8484
path: docs
8585
- name: Install requirements
8686
run: pip install -r docs/requirements.txt
8787
- name: Build documentation
8888
run: mkdocs build
89-
- uses: actions/upload-artifact@v3
89+
- uses: actions/upload-artifact@v4
9090
with:
9191
name: documentation
9292
path: site/**
@@ -95,26 +95,26 @@ jobs:
9595
runs-on: ubuntu-latest
9696
if: github.event_name == 'push' || github.event_name == 'release'
9797
steps:
98-
- uses: actions/cache@v3.3.2
98+
- uses: actions/cache@v4
9999
with:
100100
path: ~/.cache/pip
101101
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements.txt') }}
102102
restore-keys: |
103103
${{ runner.os }}-pip-
104104
- uses: actions/checkout@v4
105-
- uses: actions/setup-python@v4
105+
- uses: actions/setup-python@v5
106106
with:
107107
# TODO bump to 3.12 when mike will support it
108108
python-version: '3.11'
109-
- uses: actions/download-artifact@v3
109+
- uses: actions/download-artifact@v4
110110
with:
111111
name: benchmark_table
112112
path: examples
113-
- uses: actions/download-artifact@v3
113+
- uses: actions/download-artifact@v4
114114
with:
115115
name: benchmark_chart_light
116116
path: docs
117-
- uses: actions/download-artifact@v3
117+
- uses: actions/download-artifact@v4
118118
with:
119119
name: benchmark_chart_dark
120120
path: docs
@@ -149,4 +149,3 @@ jobs:
149149
git add versions.json
150150
git commit -m "sort versions.json"
151151
git push origin gh-pages
152-

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
language: system
1414
types: [python]
1515
- repo: https://github.com/hadialqattan/pycln
16-
rev: v2.3.0
16+
rev: v2.4.0
1717
hooks:
1818
- id: pycln
1919
- repo: https://github.com/pycqa/isort

apischema/typing.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ def get_args(tp):
5656
return res
5757

5858

59-
if sys.version_info >= (3, 11):
60-
from typing import _collect_parameters # type: ignore
59+
if sys.version_info >= (3, 13):
60+
from typing import _collect_type_parameters
61+
elif sys.version_info >= (3, 11):
62+
from typing import _collect_parameters as _collect_type_parameters # type: ignore
6163
else:
62-
from typing import _collect_type_vars as _collect_parameters
64+
from typing import _collect_type_vars as _collect_type_parameters
6365

6466

6567
def _generic_mro(result, tp):
@@ -68,7 +70,7 @@ def _generic_mro(result, tp):
6870
origin = tp
6971
result[origin] = tp
7072
if hasattr(origin, "__orig_bases__"):
71-
parameters = _collect_parameters(origin.__orig_bases__)
73+
parameters = _collect_type_parameters(origin.__orig_bases__)
7274
substitution = dict(zip(parameters, get_args(tp)))
7375
for base in origin.__orig_bases__:
7476
if get_origin(base) in result:

apischema/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from apischema.types import COLLECTION_TYPES, MAPPING_TYPES, PRIMITIVE_TYPES, AnyType
3030
from apischema.typing import (
31-
_collect_parameters,
31+
_collect_type_parameters,
3232
generic_mro,
3333
get_args,
3434
get_origin,
@@ -125,7 +125,7 @@ def get_parameters(tp: AnyType) -> Iterable[TV]:
125125
if hasattr(tp, "__parameters__"):
126126
return tp.__parameters__
127127
elif hasattr(tp, "__orig_bases__"):
128-
return _collect_parameters(tp.__orig_bases__)
128+
return _collect_type_parameters(tp.__orig_bases__)
129129
elif is_type_var(tp):
130130
return (tp,)
131131
else:

pyproject.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools==68.2.2", "wheel==0.41.2"]
2+
requires = ["setuptools==75.1.0", "wheel~=0.44.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
@@ -20,6 +20,7 @@ classifiers = [
2020
"Programming Language == Python == 3.10",
2121
"Programming Language == Python == 3.11",
2222
"Programming Language == Python == 3.12",
23+
"Programming Language == Python == 3.13",
2324
"Topic == Software Development == Libraries == Python Modules",
2425
]
2526

@@ -40,6 +41,9 @@ examples = [
4041
"sqlalchemy",
4142
]
4243

44+
[tool.setuptools.packages.find]
45+
include = ["apischema*"]
46+
4347
[tool.setuptools.package-data]
4448
apischema = ["py.typed"]
4549
"apischema.deserialization" = ["methods.c"]

scripts/cythonize.sh

100644100755
File mode changed.

scripts/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Cython==3.0.4
1+
Cython==3.0.11
2+
setuptools==75.1.0;python_version>="3.12"

tests/requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
graphql-core==3.2.3
1+
graphql-core==3.2.4
22
attrs==22.1.0
33
bson==0.5.10
4-
docstring-parser==0.15
5-
pydantic==1.10.2
4+
docstring-parser==0.16
5+
pydantic==1.10.18
66
pytest==7.4.2
77
pytest-cov==4.0.0
88
pytest-asyncio==0.20.3

0 commit comments

Comments
 (0)