55from textwrap import dedent
66
77import nox
8- import nox_poetry .patch
9- from nox .sessions import Session
8+
9+ try :
10+ from nox_poetry import Session
11+ from nox_poetry import session
12+ except ImportError :
13+ message = f"""\
14+ Nox failed to import the 'nox-poetry' package.
15+ Please install it using the following command:
16+ { sys .executable } -m pip install nox-poetry"""
17+ raise SystemExit (dedent (message ))
1018
1119
1220package = "django_sorting_bootstrap"
1321python_versions = ["3.9" , "3.8" , "3.7" ]
22+ nox .needs_version = ">= 2021.6.6"
1423nox .options .sessions = (
1524 "pre-commit" ,
1625 "safety" ,
@@ -72,7 +81,7 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
7281 hook .write_text ("\n " .join (lines ))
7382
7483
75- @nox . session (name = "pre-commit" , python = "3.9" )
84+ @session (name = "pre-commit" , python = "3.9" )
7685def precommit (session : Session ) -> None :
7786 """Lint using pre-commit."""
7887 args = session .posargs or ["run" , "--all-files" , "--show-diff-on-failure" ]
@@ -94,15 +103,15 @@ def precommit(session: Session) -> None:
94103 activate_virtualenv_in_precommit_hooks (session )
95104
96105
97- @nox . session (python = "3.9" )
106+ @session (python = "3.9" )
98107def safety (session : Session ) -> None :
99108 """Scan dependencies for insecure packages."""
100- requirements = nox_poetry . export_requirements (session )
109+ requirements = session . poetry . export_requirements ()
101110 session .install ("safety" )
102- session .run ("safety" , "check" , f "--file= { requirements } " , "--bare " )
111+ session .run ("safety" , "check" , "--full-report " , f "--file= { requirements } " )
103112
104113
105- @nox . session (python = python_versions )
114+ @session (python = python_versions )
106115def mypy (session : Session ) -> None :
107116 """Type-check using mypy."""
108117 args = session .posargs or ["src" , "tests" , "docs/conf.py" ]
@@ -113,7 +122,7 @@ def mypy(session: Session) -> None:
113122 session .run ("mypy" , f"--python-executable={ sys .executable } " , "noxfile.py" )
114123
115124
116- @nox . session (python = python_versions )
125+ @session (python = python_versions )
117126def tests (session : Session ) -> None :
118127 """Run the test suite."""
119128 session .install ("." )
@@ -125,7 +134,7 @@ def tests(session: Session) -> None:
125134 session .notify ("coverage" )
126135
127136
128- @nox . session
137+ @session
129138def coverage (session : Session ) -> None :
130139 """Produce the coverage report."""
131140 # Do not use session.posargs unless this is the only session.
@@ -140,15 +149,15 @@ def coverage(session: Session) -> None:
140149 session .run ("coverage" , * args )
141150
142151
143- @nox . session (python = python_versions )
152+ @session (python = python_versions )
144153def typeguard (session : Session ) -> None :
145154 """Runtime type checking using Typeguard."""
146155 session .install ("." )
147156 session .install ("pytest" , "pytest-django" , "typeguard" , "pygments" )
148157 session .run ("pytest" , f"--typeguard-packages={ package } " , * session .posargs )
149158
150159
151- @nox . session (python = python_versions )
160+ @session (python = python_versions )
152161def xdoctest (session : Session ) -> None :
153162 """Run examples with xdoctest."""
154163 args = session .posargs or ["all" ]
@@ -157,7 +166,7 @@ def xdoctest(session: Session) -> None:
157166 session .run ("python" , "-m" , "xdoctest" , package , * args )
158167
159168
160- @nox . session (name = "docs-build" , python = "3.9" )
169+ @session (name = "docs-build" , python = "3.9" )
161170def docs_build (session : Session ) -> None :
162171 """Build the documentation."""
163172 args = session .posargs or ["docs" , "docs/_build" ]
@@ -171,7 +180,7 @@ def docs_build(session: Session) -> None:
171180 session .run ("sphinx-build" , * args )
172181
173182
174- @nox . session (python = "3.9" )
183+ @session (python = "3.9" )
175184def docs (session : Session ) -> None :
176185 """Build and serve the documentation with live reloading on file changes."""
177186 args = session .posargs or ["--open-browser" , "docs" , "docs/_build" ]
0 commit comments