Debian Codegraph @

noxfile.py

raw
1 import os
2
3 import nox
4
5
6 @nox.session
7 def docs(session):
8 session.install(
9 "Django==5.2",
10 "Sphinx>=7.4.7,<8",
11 "sphinx_rtd_theme",
12 "djangorestframework>=3.15.2,<4",
13 "django-ninja>=1.3.0,<2",
14 "snowballstemmer<3", # https://github.com/sphinx-doc/sphinx/issues/13533
15 )
16 session.run("make", "docs")
17
18
19 @nox.session(tags=["lint"])
20 def lint(session):
21 session.install("bandit")
22 session.run("bandit", "-c", "pyproject.toml", "-r", "allauth/")
23
24
25 @nox.session(tags=["lint"])
26 def isort(session):
27 session.install("isort==5.13.2")
28 session.run("isort", "--check-only", "--diff", "--gitignore", ".")
29
30
31 @nox.session(tags=["lint"])
32 def flake8(session):
33 session.install("flake8==7.2.0")
34 session.run("flake8", "allauth/", "tests/")
35
36
37 @nox.session(tags=["lint"])
38 def black(session):
39 session.install("black==24.4.0")
40 session.run("black", "--check", ".")
41
42
43 @nox.session(tags=["lint"])
44 def djlint(session):
45 session.install("djlint==1.36.4")
46 session.run(
47 "djlint", "--configuration", ".djlintrc", "--check", "./allauth", "./examples"
48 )
49
50
51 DJANGO_PYTHON_REQ = {
52 "4.2.20": ("3.10", "3.11", "3.12"),
53 "5.1": ("3.10", "3.11", "3.12", "3.13"),
54 "5.2": ("3.10", "3.11", "3.12", "3.13", "3.14"),
55 "6.0": ("3.12", "3.13", "3.14"),
56 "6.1": ("3.12", "3.13", "3.14"),
57 }
58 DJANGO_LTS = "5.2"
59
60
61 @nox.session(python=["3.10", "3.11", "3.12", "3.13", "3.14"])
62 @nox.parametrize("django", list(DJANGO_PYTHON_REQ.keys()))
63 @nox.parametrize(
64 "project", ["regular", "headless_only", "account_only", "login_required_mw"]
65 )
66 def test(session, django, project):
67 django_version = tuple(map(int, django.split(".")))
68 if django != DJANGO_LTS:
69 last_django_python = DJANGO_PYTHON_REQ[django][-1]
70 first_django_python = DJANGO_PYTHON_REQ[django][0]
71 if session.python not in (first_django_python, last_django_python):
72 print(
73 f"Skipping: only current LTS is tested against python{session.python}, not Django {django}"
74 )
75 return
76
77 if project == "login_required_mw" and django_version < (5, 1):
78 print(f"Skipping: project {project} does not support Django {django}")
79 return
80 if session.python not in DJANGO_PYTHON_REQ[django]:
81 print(f"Skipping: Django {django} does not support python{session.python}")
82 return
83 django_version = f"{django}.0" if django != "6.2" else "6.2rc1"
84 session.install(
85 f"django~={django_version}",
86 "pytest>=8.3.5,<9",
87 "pytest-asyncio==1.3.0",
88 # pytest-django 4.13 dropped support for Django 4.2 and 5.1.
89 "pytest-django>=4.11,<4.13",
90 "Pillow>=9.0",
91 "coverage==7.6.1",
92 # SAML is disabled in CI
93 # "python3-saml==1.16.0",
94 # "xmlsec==1.3.14",
95 # "lxml==5.2.1",
96 "pyyaml>=6.0.2,<7",
97 "psycopg2-binary>=2.9.10,<3",
98 # The released DRF 3.17.2 is missing the Django 6.1+ compat fix (its
99 # `cc_delim_re` import was only replaced on a post-tag main commit), so
100 # pin to that specific commit until a fixed release is out.
101 "djangorestframework @ git+https://github.com/encode/django-rest-framework@fbb02d9be78b1e232784dbb813c3fa118c1ba076",
102 "django-ninja>=1.3.0,<2",
103 "mypy==1.19.1",
104 ".[mfa,openid,socialaccount,steam]", # SAML is disabled in CI
105 )
106 session.run("/bin/sh", "-c", "cd allauth; python ../manage.py compilemessages")
107 run_coveralls = (
108 os.environ.get("GITHUB_TOKEN")
109 and project == "regular"
110 and django == "5.2"
111 and session.python == "3.14"
112 )
113 if run_coveralls:
114 session.install("coveralls")
115 session.run(
116 "coverage",
117 "run",
118 "-m",
119 "pytest",
120 f"--ds=tests.projects.{project}.settings",
121 "tests/",
122 )
123 if run_coveralls:
124 session.run("coveralls", "--service=github")
125 if django == "5.2" and session.python == "3.14":
126 session.install(
127 "django-stubs~=5.2.9",
128 "types-requests==2.32.4.20260107",
129 )
130 session.run("mypy", "allauth")