import os import nox @nox.session def docs(session): session.install( "Django==5.2", "Sphinx>=7.4.7,<8", "sphinx_rtd_theme", "djangorestframework>=3.15.2,<4", "django-ninja>=1.3.0,<2", "snowballstemmer<3", # https://github.com/sphinx-doc/sphinx/issues/13533 ) session.run("make", "docs") @nox.session(tags=["lint"]) def lint(session): session.install("bandit") session.run("bandit", "-c", "pyproject.toml", "-r", "allauth/") @nox.session(tags=["lint"]) def isort(session): session.install("isort==5.13.2") session.run("isort", "--check-only", "--diff", "--gitignore", ".") @nox.session(tags=["lint"]) def flake8(session): session.install("flake8==7.2.0") session.run("flake8", "allauth/", "tests/") @nox.session(tags=["lint"]) def black(session): session.install("black==24.4.0") session.run("black", "--check", ".") @nox.session(tags=["lint"]) def djlint(session): session.install("djlint==1.36.4") session.run( "djlint", "--configuration", ".djlintrc", "--check", "./allauth", "./examples" ) DJANGO_PYTHON_REQ = { "4.2.20": ("3.10", "3.11", "3.12"), "5.1": ("3.10", "3.11", "3.12", "3.13"), "5.2": ("3.10", "3.11", "3.12", "3.13", "3.14"), "6.0": ("3.12", "3.13", "3.14"), "6.1": ("3.12", "3.13", "3.14"), } DJANGO_LTS = "5.2" @nox.session(python=["3.10", "3.11", "3.12", "3.13", "3.14"]) @nox.parametrize("django", list(DJANGO_PYTHON_REQ.keys())) @nox.parametrize( "project", ["regular", "headless_only", "account_only", "login_required_mw"] ) def test(session, django, project): django_version = tuple(map(int, django.split("."))) if django != DJANGO_LTS: last_django_python = DJANGO_PYTHON_REQ[django][-1] first_django_python = DJANGO_PYTHON_REQ[django][0] if session.python not in (first_django_python, last_django_python): print( f"Skipping: only current LTS is tested against python{session.python}, not Django {django}" ) return if project == "login_required_mw" and django_version < (5, 1): print(f"Skipping: project {project} does not support Django {django}") return if session.python not in DJANGO_PYTHON_REQ[django]: print(f"Skipping: Django {django} does not support python{session.python}") return django_version = f"{django}.0" if django != "6.2" else "6.2rc1" session.install( f"django~={django_version}", "pytest>=8.3.5,<9", "pytest-asyncio==1.3.0", # pytest-django 4.13 dropped support for Django 4.2 and 5.1. "pytest-django>=4.11,<4.13", "Pillow>=9.0", "coverage==7.6.1", # SAML is disabled in CI # "python3-saml==1.16.0", # "xmlsec==1.3.14", # "lxml==5.2.1", "pyyaml>=6.0.2,<7", "psycopg2-binary>=2.9.10,<3", # The released DRF 3.17.2 is missing the Django 6.1+ compat fix (its # `cc_delim_re` import was only replaced on a post-tag main commit), so # pin to that specific commit until a fixed release is out. "djangorestframework @ git+https://github.com/encode/django-rest-framework@fbb02d9be78b1e232784dbb813c3fa118c1ba076", "django-ninja>=1.3.0,<2", "mypy==1.19.1", ".[mfa,openid,socialaccount,steam]", # SAML is disabled in CI ) session.run("/bin/sh", "-c", "cd allauth; python ../manage.py compilemessages") run_coveralls = ( os.environ.get("GITHUB_TOKEN") and project == "regular" and django == "5.2" and session.python == "3.14" ) if run_coveralls: session.install("coveralls") session.run( "coverage", "run", "-m", "pytest", f"--ds=tests.projects.{project}.settings", "tests/", ) if run_coveralls: session.run("coveralls", "--service=github") if django == "5.2" and session.python == "3.14": session.install( "django-stubs~=5.2.9", "types-requests==2.32.4.20260107", ) session.run("mypy", "allauth")