99# dependencies = [
1010# "nox",
1111# "nox-uv",
12+ # "requests",
1213# ]
1314# ///
1415""" Entry point script for testing, linting, and development of the package.
3132 $ uv run noxfile.py -s dev -P 3.X
3233 $ uv run noxfile.py -s dev -P pypy-3.X # For PyPy
3334"""
35+ from itertools import groupby
36+
3437import nox
38+ from packaging .requirements import Requirement
39+ from packaging .version import Version
40+ import requests
3541
3642
3743# Python versions supported and tested against: 3.8, 3.9, 3.10, 3.11
3844PYTHON_MINOR_VERSION_MIN = 8
3945PYTHON_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" ]
4246
4347nox .options .default_venv_backend = "uv"
4448
@@ -56,14 +60,37 @@ def lint(session):
5660 "--max-line-length=127" , "--statistics" , "--extend-exclude" , ".venv" )
5761
5862
63+ def parametrize_test_versions ():
64+ """Parametrize the session with all supported Python & SQLAlchemy versions."""
65+ response = requests .get ("https://pypi.org/pypi/SQLAlchemy/json" )
66+ response .raise_for_status ()
67+ data = response .json ()
68+ all_major_and_minor_sqlalchemy_versions = [
69+ Version (f"{ major } .{ minor } " )
70+ for (major , minor ), _ in groupby (
71+ sorted (Version (version ) for version in data ["releases" ].keys ()),
72+ key = lambda v : (v .major , v .minor )
73+ )
74+ ]
75+
76+ with open ("requirements.txt" , "r" ) as f :
77+ requirement = Requirement (f .read ().strip ())
78+ filtered_sqlalchemy_versions = [
79+ version for version in all_major_and_minor_sqlalchemy_versions
80+ if version in requirement .specifier
81+ ]
82+
83+ return [
84+ (f"{ interpreter } 3.{ python_minor } " , str (sqlalchemy_version ))
85+ for interpreter in ("" , "pypy-" )
86+ for python_minor in range (PYTHON_MINOR_VERSION_MIN , PYTHON_MINOR_VERSION_MAX + 1 )
87+ for sqlalchemy_version in filtered_sqlalchemy_versions
88+ # SQLA 1.1 or below doesn't seem to support Python 3.10+
89+ if sqlalchemy_version >= Version ("1.2" ) or python_minor <= 9 ]
90+
91+
5992@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 ])
93+ @nox .parametrize ("python,sqlalchemy" , parametrize_test_versions ())
6794def test (session , sqlalchemy ):
6895 """Run tests with pytest.
6996
0 commit comments