Skip to content

Commit ce30914

Browse files
authored
feat: add support for Python 3.13 (#815)
1 parent 52d3d55 commit ce30914

File tree

7 files changed

+30
-32
lines changed

7 files changed

+30
-32
lines changed

.github/workflows/_build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# Even though we run the build in a matrix to check against different platforms, due to a known
88
# limitation of reusable workflows that do not support setting strategy property from the caller
9-
# workflow, we only generate artifacts for ubuntu-latest and Python 3.12, which can be used to
9+
# workflow, we only generate artifacts for ubuntu-latest and Python 3.13, which can be used to
1010
# create a release. For details see:
1111
#
1212
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations
@@ -35,7 +35,7 @@ permissions:
3535
contents: read
3636
env:
3737
ARTIFACT_OS: ubuntu-latest # The default OS for release.
38-
ARTIFACT_PYTHON: '3.12' # The default Python version for release.
38+
ARTIFACT_PYTHON: '3.13' # The default Python version for release.
3939

4040
jobs:
4141
build:
@@ -51,7 +51,7 @@ jobs:
5151
# It is recommended to pin a Runner version specifically:
5252
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
5353
os: [ubuntu-latest, macos-latest, windows-latest]
54-
python: ['3.10', '3.11', '3.12']
54+
python: ['3.10', '3.11', '3.12', '3.13']
5555
steps:
5656

5757
- name: Harden Runner

.github/workflows/codeql-analysis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3434
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3535
language: [python]
36-
python: ['3.12']
36+
python: ['3.13']
3737
steps:
3838

3939
- name: Harden Runner

.github/workflows/pr-conventional-commits.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Set up Python
3030
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
3131
with:
32-
python-version: '3.12'
32+
python-version: '3.13'
3333

3434
# Install Commitizen without using the package's Makefile: that's much faster than
3535
# creating a venv and installing heaps of dependencies that aren't required for this job.

.github/workflows/release.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- name: Set up Python
4545
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
4646
with:
47-
python-version: '3.12'
47+
python-version: '3.13'
4848

4949
- name: Set up Commitizen
5050
run: |
@@ -111,7 +111,7 @@ jobs:
111111
- name: Download artifact
112112
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
113113
with:
114-
name: artifact-ubuntu-latest-python-3.12
114+
name: artifact-ubuntu-latest-python-3.13
115115
path: dist
116116

117117
# Verify hashes by first computing hashes for the artifacts and then comparing them
@@ -128,7 +128,7 @@ jobs:
128128
- name: Set up Python
129129
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
130130
with:
131-
python-version: '3.12'
131+
python-version: '3.13'
132132

133133
- name: Set up Commitizen
134134
run: |
@@ -250,7 +250,7 @@ jobs:
250250
# Github disallows passing environment variables as arguments to a reusable
251251
# workflow, so we have to duplicate these values here. Related discussion
252252
# here: https://github.com/actions/toolkit/issues/931
253-
artifact-name: artifact-ubuntu-latest-python-3.12
253+
artifact-name: artifact-ubuntu-latest-python-3.13
254254
git-user-name: jenstroeger
255255
git-user-email: [email protected]
256256
secrets:

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ endif
5656
.PHONY: all
5757
all: check test dist docs
5858

59-
# Create a virtual environment, either for Python3.12 (default) or using
59+
# Create a virtual environment, either for Python3.13 (default) or using
6060
# the Python interpreter specified in the PYTHON environment variable. Also
6161
# create an empty pip.conf file to ensure that `pip config` modifies this
6262
# venv only, unless told otherwise. For more background, see:
@@ -70,8 +70,8 @@ venv:
7070
echo "Found an inactive Python virtual environment, please activate or nuke it" && exit 1; \
7171
fi
7272
if [ -z "${PYTHON}" ]; then \
73-
echo "Creating virtual environment in .venv/ for python3.12"; \
74-
python3.12 -m venv --upgrade-deps --prompt . .venv; \
73+
echo "Creating virtual environment in .venv/ for python3.13"; \
74+
python3.13 -m venv --upgrade-deps --prompt . .venv; \
7575
else \
7676
echo "Creating virtual environment in .venv/ for ${PYTHON}"; \
7777
${PYTHON} -m venv --upgrade-deps --prompt . .venv; \

README.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The badges above give you an idea of what this project template provides. It’s
3232

3333
### Typing
3434

35-
The package requires a minimum of [Python 3.10](https://www.python.org/downloads/release/python-31014/), and it supports [Python 3.11](https://www.python.org/downloads/release/python-3118/) and [Python 3.12](https://www.python.org/downloads/release/python-3121/) (default). All code requires comprehensive [typing](https://docs.python.org/3/library/typing.html). The [mypy](http://mypy-lang.org/) static type checker and the [flake8-pyi](https://github.com/PyCQA/flake8-pyi) plugin are invoked by git hooks and through a Github Action to enforce continuous type checks on Python source and [stub files](https://peps.python.org/pep-0484/#stub-files). Make sure to add type hints to your code or to use [stub files](https://mypy.readthedocs.io/en/stable/stubs.html) for types, to ensure that users of your package can `import` and type-check your code (see also [PEP 561](https://www.python.org/dev/peps/pep-0561/)).
35+
The package requires a minimum of [Python 3.10](https://www.python.org/downloads/release/python-31015/), and it supports [Python 3.11](https://www.python.org/downloads/release/python-31110/), [Python 3.12](https://www.python.org/downloads/release/python-3127/) and [Python 3.13](https://www.python.org/downloads/release/python-3130/) (default). All code requires comprehensive [typing](https://docs.python.org/3/library/typing.html). The [mypy](http://mypy-lang.org/) static type checker and the [flake8-pyi](https://github.com/PyCQA/flake8-pyi) plugin are invoked by git hooks and through a Github Action to enforce continuous type checks on Python source and [stub files](https://peps.python.org/pep-0484/#stub-files). Make sure to add type hints to your code or to use [stub files](https://mypy.readthedocs.io/en/stable/stubs.html) for types, to ensure that users of your package can `import` and type-check your code (see also [PEP 561](https://www.python.org/dev/peps/pep-0561/)).
3636

3737
### Quality assurance
3838

@@ -99,19 +99,19 @@ If you’d like to start your own Python project from scratch, you can either co
9999
To develop your new package, first create a [virtual environment](https://docs.python.org/3/tutorial/venv.html) by either using the [Makefile](https://www.gnu.org/software/make/manual/make.html#toc-An-Introduction-to-Makefiles):
100100

101101
```bash
102-
make venv # Create a new virtual environment in .venv folder using Python 3.10.
102+
make venv # Create a new virtual environment in .venv folder using Python 3.13.
103103
```
104104

105105
or for a specific version of Python:
106106

107107
```bash
108-
PYTHON=python3.10 make venv # Same virtual environment for a different Python version.
108+
PYTHON=python3.12 make venv # Same virtual environment for a different Python version.
109109
```
110110

111111
or manually:
112112

113113
```bash
114-
python3.12 -m venv .venv # Or use .venv312 for more than one local virtual environments.
114+
python3.13 -m venv .venv # Or use .venv313 for more than one local virtual environments.
115115
```
116116

117117
When working with this Makefile _it is important to always [activate the virtual environment](https://docs.python.org/3/library/venv.html)_ because some of the [git hooks](#git-hooks) (see below) depend on that:
@@ -171,45 +171,42 @@ Both statement and branch coverage are being tracked using [coverage](https://gi
171171
```
172172
Run unit tests...........................................................Passed
173173
- hook id: pytest
174-
- duration: 0.6s
174+
- duration: 1.74s
175175
176176
============================= test session starts ==============================
177-
platform darwin -- Python 3.11.7, pytest-7.4.4, pluggy-1.3.0 -- /path/to/python-package-template/.venv/bin/python
177+
platform darwin -- Python 3.13.0, pytest-8.3.3, pluggy-1.5.0 -- /path/to/python-package-template/.venv/bin/python
178178
cachedir: .pytest_cache
179-
hypothesis profile 'default-with-verbose-verbosity-with-explain-phase' -> max_examples=500, verbosity=Verbosity.verbose, phases=(Phase.explicit, Phase.reuse, Phase.generate, Phase.target, Phase.shrink, Phase.explain), database=DirectoryBasedExampleDatabase('/path/to/python-package-template/.hypothesis/examples')
179+
hypothesis profile 'default-with-verbose-verbosity' -> max_examples=500, verbosity=Verbosity.verbose, database=DirectoryBasedExampleDatabase(PosixPath('/path/to/python-package-template/.hypothesis/examples'))
180180
rootdir: /path/to/python-package-template
181181
configfile: pyproject.toml
182-
plugins: custom-exit-code-0.3.0, cov-4.1.0, doctestplus-1.1.0, hypothesis-6.90.0, env-1.1.1
182+
plugins: cov-5.0.0, hypothesis-6.111.2, env-1.1.3, custom-exit-code-0.3.0, doctestplus-1.2.1
183183
collected 3 items
184184
185185
src/package/something.py::package.something.Something.do_something PASSED [ 33%]
186-
tests/test_something.py::test_something PASSED [ 66%]
187-
docs/source/index.rst::index.rst PASSED [100%]
186+
tests/test_something.py::test_something PASSED [ 66%]
187+
docs/source/index.rst::index.rst PASSED [100%]
188188
189-
---------- coverage: platform darwin, python 3.11.7-final-0 ----------
189+
---------- coverage: platform darwin, python 3.13.0-final-0 ----------
190190
Name Stmts Miss Branch BrPart Cover Missing
191191
----------------------------------------------------------------------
192192
src/package/__init__.py 1 0 0 0 100%
193-
src/package/something.py 4 0 2 0 100%
193+
src/package/something.py 4 0 0 0 100%
194194
----------------------------------------------------------------------
195-
TOTAL 5 0 2 0 100%
195+
TOTAL 5 0 0 0 100%
196196
197197
Required test coverage of 100.0% reached. Total coverage: 100.00%
198198
============================ Hypothesis Statistics =============================
199199
200200
tests/test_something.py::test_something:
201201
202-
- during reuse phase (0.00 seconds):
203-
- Typical runtimes: < 1ms, of which < 1ms in data generation
204-
- 1 passing examples, 0 failing examples, 0 invalid examples
205-
206202
- during generate phase (0.00 seconds):
207-
- Typical runtimes: < 1ms, of which < 1ms in data generation
208-
- 1 passing examples, 0 failing examples, 0 invalid examples
203+
- Typical runtimes: ~ 0-1 ms, of which < 1ms in data generation
204+
- 2 passing examples, 0 failing examples, 0 invalid examples
209205
210206
- Stopped because nothing left to do
211207
212-
============================== 3 passed in 0.05s ===============================
208+
209+
============================== 3 passed in 0.08s ===============================
213210
```
214211
Note that code that’s not covered by tests is listed under the `Missing` column, and branches not taken too. The net effect of enforcing 100% code and branch coverage is that every new major and minor feature, every code change, and every fix are being tested (keeping in mind that high _coverage_ does not imply comprehensive, meaningful _test data_).
215212

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ classifiers = [
2525
"Programming Language :: Python :: 3.10",
2626
"Programming Language :: Python :: 3.11",
2727
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3.13",
2829
"Programming Language :: Python :: 3 :: Only",
2930
"Programming Language :: Python :: Implementation :: CPython",
3031
"Topic :: Software Development :: Libraries :: Python Modules",

0 commit comments

Comments
 (0)