9
9
# dependencies = [
10
10
# "nox",
11
11
# "nox-uv",
12
+ # "requests",
12
13
# ]
13
14
# ///
14
15
""" Entry point script for testing, linting, and development of the package.
31
32
$ uv run noxfile.py -s dev -P 3.X
32
33
$ uv run noxfile.py -s dev -P pypy-3.X # For PyPy
33
34
"""
35
+ from itertools import groupby
36
+
34
37
import nox
38
+ from packaging .requirements import Requirement
39
+ from packaging .version import Version
40
+ import requests
35
41
36
42
37
43
# Python versions supported and tested against: 3.8, 3.9, 3.10, 3.11
38
44
PYTHON_MINOR_VERSION_MIN = 8
39
45
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
46
43
47
nox .options .default_venv_backend = "uv"
44
48
@@ -56,14 +60,37 @@ def lint(session):
56
60
"--max-line-length=127" , "--statistics" , "--extend-exclude" , ".venv" )
57
61
58
62
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
+
59
92
@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 ())
67
94
def test (session , sqlalchemy ):
68
95
"""Run tests with pytest.
69
96
0 commit comments