Skip to content

Commit 853fd1b

Browse files
authored
Support Python 3.10 & 3.11 (#97)
* Switch to pytest * Add a noxfile.py for nox config * Remove nose specific code from tests * Update noxfile for pytest * Drop tests for EOL Python 3.7 * Add test env for Python 3.10 * Add tests env for Python 3.11 * Add session for linting * Remove redundant requirements * Update Github Actions for nox/pytest * Add backend for Github Actions * Skip coveralls for lint step * Adjust naming for Github Actions * Add Github token * Enable diagnostics * Generate xml coverage for Github Actions * Rename build step * Add additional dependencies * Use different base action * Remove container constraint * Test Python 3.7 on Github Actions * Undo Python * Defer SQLA 1.4 changes * Add session for dev setup * Stick to uv * Add EOL * Add an editorconfig * Ignore .venv when linting * Install test dependencies in .venv * Add hypothesis tests for better coverage * Use fewer runs * Tweak hypothesis settings * Switch to uv build * Declare that delete_node consumes data * Document pipeline steps * Add docstrings and copyright information * Ignore artifact folders * Remove tox config * Remove nose related files and comments * Update supported Python versions * Add a contributor guide * Update project description * Remove dead link * Fix typo * Link to contributor's guide * Add docstrings * Fix link * Update changelog
1 parent 705fd9d commit 853fd1b

File tree

16 files changed

+321
-140
lines changed

16 files changed

+321
-140
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root = true
2+
3+
[*]
4+
insert_final_newline = true
5+
trim_trailing_whitespace = true

.github/workflows/run-tests.yml

Lines changed: 33 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Check code and run tests
22

33
on:
44
push:
@@ -10,71 +10,45 @@ permissions:
1010
contents: read
1111

1212
jobs:
13-
test:
13+
generate-jobs:
14+
name: Generate build matrix for tests
15+
runs-on: ubuntu-latest
16+
outputs:
17+
session: ${{ steps.set-matrix.outputs.session }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: astral-sh/setup-uv@v6
21+
- name: Generate build matrix
22+
id: set-matrix
23+
shell: bash
24+
run: echo session=$(uv run noxfile.py --json -l | jq -c '[.[].session]') | tee --append $GITHUB_OUTPUT
25+
checks:
26+
name: Run ${{ matrix.session }}
27+
needs: [generate-jobs]
28+
runs-on: ubuntu-latest
1429
strategy:
30+
fail-fast: false
1531
matrix:
16-
python-version:
17-
- "3.7"
18-
- "3.8"
19-
- "3.9"
20-
- "pypy-3.7"
21-
- "pypy-3.8"
22-
- "pypy-3.9"
23-
sqlalchemy-version:
24-
- "1.0.0"
25-
- "1.1.0"
26-
- "1.2.0"
27-
- "1.3.0"
28-
include:
29-
- os: ubuntu-22.04
30-
python-version: "3.7"
31-
- os: ubuntu-latest
32-
python-version: "3.8"
33-
- os: ubuntu-latest
34-
python-version: "3.9"
35-
- os: ubuntu-latest
36-
python-version: "pypy-3.7"
37-
- os: ubuntu-latest
38-
python-version: "pypy-3.8"
39-
- os: ubuntu-latest
40-
python-version: "pypy-3.9"
41-
42-
runs-on: ${{ matrix.os }}
32+
session: ${{ fromJson(needs.generate-jobs.outputs.session) }}
4333
steps:
4434
- uses: actions/checkout@v4
45-
- name: Set up Python ${{ matrix.python-version }}
46-
uses: actions/setup-python@v5
47-
with:
48-
python-version: ${{ matrix.python-version }}
49-
- name: Install dependencies
50-
run: |
51-
python -m pip install --upgrade pip
52-
pip install SQLAlchemy~=${{ matrix.sqlalchemy-version }}
53-
pip install -r requirements.txt -r requirements-test.txt coveralls
54-
- name: Lint with flake8
55-
run: |
56-
# stop the build if there are Python syntax errors or undefined names
57-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
58-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
59-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
60-
- name: Test with nose
61-
run: |
62-
nosetests --with-coverage --cover-package=sqlalchemy_mptt --cover-erase
35+
- uses: astral-sh/setup-uv@v6
36+
- run: uv tool install nox --with nox-uv
37+
- name: Run nox
38+
run: uvx nox -s "${{ matrix.session }}" -- --coverage
6339
- name: Upload coverage data
64-
run: coveralls
65-
env:
66-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67-
COVERALLS_PARALLEL: true
40+
if: ${{ matrix.session != 'lint' }}
41+
uses: coverallsapp/github-action@v2
42+
with:
43+
flag-name: run-${{ join(matrix.*, '-') }}
44+
parallel: true
45+
debug: true
6846

6947
coveralls_finish:
7048
name: Finalize coverage
71-
needs: test
49+
needs: checks
7250
runs-on: ubuntu-latest
73-
container: python:3-slim
7451
steps:
75-
- name: Install coveralls
76-
run: pip3 install --upgrade coveralls
77-
- name: Finished
78-
run: coveralls --finish
79-
env:
80-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
- uses: coverallsapp/github-action@v2
53+
with:
54+
parallel-finished: true

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ _build
2929
_themes
3030
.aider.*
3131
.vscode/
32+
coverage.xml
33+
.hypothesis/
34+
.nox
35+
.pytest_cache
36+
.venv

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Versions releases 0.2.x & above
22
###############################
33

4+
0.4.0 (Unreleased)
5+
==================
6+
7+
see issue #97
8+
9+
- Support for Python 3.10 and 3.11
10+
- Dropped support for Python 3.7
11+
412
0.3.0 (2025-05-10)
513
==================
614

Makefile

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ If you have any questions:
270270
* Contact the maintainer via email: fayaz.yusuf.khan@gmail.com
271271
* Contact the author via email: sacrud@uralbash.ru or #sacrud IRC channel |IRC Freenode|
272272

273+
Refer the detailed contribution guide in the `docs <https://sqlalchemy-mptt.readthedocs.io/en/latest/CONTRIBUTING.html>`_
274+
for more information on setting up the development environment, running tests, and contributing to the project.
275+
273276
License
274277
=======
275278

docs/CONTRIBUTING.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Contribution Guidelines
2+
=======================
3+
4+
All types of contributions are welcome: suggestions, ideas, commits
5+
with new features, bug fixes, refactoring, docs, tests, translations, etc...
6+
7+
If you have any questions:
8+
9+
* Use the `Discussion board <https://github.com/uralbash/sqlalchemy_mptt/discussions>`_
10+
* Contact the maintainer via email: fayaz.yusuf.khan@gmail.com
11+
* Contact the author via email: sacrud@uralbash.ru or #sacrud IRC channel |IRC Freenode|
12+
13+
Development Setup
14+
-----------------
15+
16+
To set up the development environment, you can run:
17+
18+
.. code-block:: bash
19+
20+
# Install uv
21+
$ pip install uv
22+
# Run the noxfile.py script
23+
$ uv run noxfile.py dev
24+
25+
By default, this will create a virtual environment with Python 3.8 and install all the required dependencies.
26+
If you need to setup the development environment with a specific Python version, you can run:
27+
28+
.. code-block:: bash
29+
30+
$ uv run noxfile.py dev -P 3.10
31+
32+
Running Tests
33+
-------------
34+
35+
To run the tests and linters, you can use the following command:
36+
37+
.. code-block:: bash
38+
39+
$ uv run noxfile.py
40+
41+
42+
.. |IRC Freenode| image:: https://img.shields.io/badge/irc-freenode-blue.svg
43+
:target: https://webchat.freenode.net/?channels=sacrud

docs/index.rst

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,14 @@ Tutorial
4646
tut_flask.rst
4747

4848
A lot of examples and logic in
49-
:py:mod:`sqlalchemy_mptt.tests.cacses`
49+
:py:mod:`sqlalchemy_mptt.tests.cases`
5050

5151
Support and Development
5252
=======================
5353

54-
To report bugs, use the `issue tracker
55-
<https://github.com/uralbash/sqlalchemy_mptt/issues>`_.
56-
57-
We welcome any contribution: suggestions, ideas, commits with new
58-
futures, bug fixes, refactoring, docs, tests, translations, etc...
59-
60-
If you have any questions:
54+
.. toctree::
6155

62-
* Use the `Discussion board <https://github.com/uralbash/sqlalchemy_mptt/discussions>`_
63-
* Contact the maintainer via email: fayaz.yusuf.khan@gmail.com
64-
* Contact the author via email: sacrud@uralbash.ru or #sacrud IRC channel |IRC Freenode|
56+
CONTRIBUTING.rst
6557

6658
Changelog
6759
=========
@@ -81,5 +73,3 @@ Indices and tables
8173

8274
.. _ps_tree: https://github.com/sacrud/ps_tree
8375
.. _pyramid_pages: https://github.com/uralbash/pyramid_pages
84-
.. |IRC Freenode| image:: https://img.shields.io/badge/irc-freenode-blue.svg
85-
:target: https://webchat.freenode.net/?channels=sacrud

noxfile.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (c) 2025 Fayaz Yusuf Khan <fayaz.yusuf.khan@gmail.com>
4+
#
5+
# Distributed under terms of the MIT license.
6+
#
7+
# /// script
8+
# requires-python = ">=3.9"
9+
# dependencies = [
10+
# "nox",
11+
# "nox-uv",
12+
# ]
13+
# ///
14+
""" Entry point script for testing, linting, and development of the package.
15+
16+
This project uses Nox to create isolated environments.
17+
18+
Requirements:
19+
- uv
20+
21+
Usage:
22+
23+
Run all tests and linting:
24+
$ uv run noxfile.py
25+
Run all tests with coverage and linting:
26+
$ uv run noxfile.py -- --coverage
27+
28+
Set up a development environment with the default Python version (3.8):
29+
$ uv run noxfile.py dev
30+
Set up a development environment with a specific Python version:
31+
$ uv run noxfile.py dev -P 3.X
32+
$ uv run noxfile.py dev -P pypy-3.X # For PyPy
33+
"""
34+
import nox
35+
36+
37+
# Python versions supported and tested against: 3.8, 3.9, 3.10, 3.11
38+
PYTHON_MINOR_VERSION_MIN = 8
39+
PYTHON_MINOR_VERSION_MAX = 11
40+
# SQLAlchemy versions supported and tested against: 1.0, 1.1, 1.2, 1.3
41+
SQLALCHEMY_VERSIONS = ["1.0", "1.1", "1.2", "1.3"]
42+
43+
nox.options.default_venv_backend = "uv"
44+
45+
46+
@nox.session()
47+
def lint(session):
48+
"""Run flake8."""
49+
session.install("flake8")
50+
# stop the linter if there are Python syntax errors or undefined names
51+
session.run(
52+
"flake8", ".", "--count", "--select=E9,F63,F7,F82", "--show-source", "--statistics", "--extend-exclude", ".venv")
53+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
54+
session.run(
55+
"flake8", ".", "--count", "--exit-zero", "--max-complexity=10",
56+
"--max-line-length=127", "--statistics", "--extend-exclude", ".venv")
57+
58+
59+
@nox.session()
60+
@nox.parametrize("python,sqlalchemy",
61+
[(f"{interpreter}3.{python_minor}", sqlalchemy_version)
62+
for interpreter in ("", "pypy-")
63+
for python_minor in range(PYTHON_MINOR_VERSION_MIN, PYTHON_MINOR_VERSION_MAX + 1)
64+
for sqlalchemy_version in SQLALCHEMY_VERSIONS
65+
# SQLA 1.1 or below doesn't seem to support Python 3.10+
66+
if sqlalchemy_version >= "1.2" or python_minor <= 9])
67+
def test(session, sqlalchemy):
68+
"""Run tests with pytest.
69+
70+
Use the --coverage option to run tests with coverage.
71+
For fine-grained control over running the tests, refer the nox documentation: https://nox.thea.codes/en/stable/usage.html
72+
"""
73+
session.install("-r", "requirements-test.txt")
74+
session.install(f"sqlalchemy~={sqlalchemy}.0")
75+
if "--coverage" in session.posargs:
76+
session.run("coverage", "run", "--source=sqlalchemy_mptt", "-m", "pytest", "sqlalchemy_mptt/")
77+
session.run("coverage", "xml")
78+
else:
79+
session.run("pytest", "sqlalchemy_mptt/")
80+
81+
82+
@nox.session(default=False)
83+
def dev(session):
84+
"""Set up a development environment.
85+
This will create a virtual environment and install the package in editable mode in .venv.
86+
87+
To use a specific Python version, use the -P option:
88+
$ uv run noxfile.py dev -P 3.X
89+
$ uv run noxfile.py dev -P pypy-3.X # For PyPy
90+
"""
91+
session.run("uv", "venv", "--python", session.python or f"3.{PYTHON_MINOR_VERSION_MIN}", "--seed")
92+
session.run(".venv/bin/pip", "install", "-r", "requirements-test.txt", external=True)
93+
session.run(".venv/bin/pip", "install", "-e", ".", external=True)
94+
95+
96+
if __name__ == "__main__":
97+
nox.main()

requirements-test.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
nose
2-
flake8
3-
coverage
1+
pytest
2+
pytest-cov
3+
hypothesis

0 commit comments

Comments
 (0)