5
5
from textwrap import dedent
6
6
7
7
import 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 ))
10
18
11
19
12
20
package = "django_sorting_bootstrap"
13
21
python_versions = ["3.9" , "3.8" , "3.7" ]
22
+ nox .needs_version = ">= 2021.6.6"
14
23
nox .options .sessions = (
15
24
"pre-commit" ,
16
25
"safety" ,
@@ -72,7 +81,7 @@ def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
72
81
hook .write_text ("\n " .join (lines ))
73
82
74
83
75
- @nox . session (name = "pre-commit" , python = "3.9" )
84
+ @session (name = "pre-commit" , python = "3.9" )
76
85
def precommit (session : Session ) -> None :
77
86
"""Lint using pre-commit."""
78
87
args = session .posargs or ["run" , "--all-files" , "--show-diff-on-failure" ]
@@ -94,15 +103,15 @@ def precommit(session: Session) -> None:
94
103
activate_virtualenv_in_precommit_hooks (session )
95
104
96
105
97
- @nox . session (python = "3.9" )
106
+ @session (python = "3.9" )
98
107
def safety (session : Session ) -> None :
99
108
"""Scan dependencies for insecure packages."""
100
- requirements = nox_poetry . export_requirements (session )
109
+ requirements = session . poetry . export_requirements ()
101
110
session .install ("safety" )
102
- session .run ("safety" , "check" , f "--file= { requirements } " , "--bare " )
111
+ session .run ("safety" , "check" , "--full-report " , f "--file= { requirements } " )
103
112
104
113
105
- @nox . session (python = python_versions )
114
+ @session (python = python_versions )
106
115
def mypy (session : Session ) -> None :
107
116
"""Type-check using mypy."""
108
117
args = session .posargs or ["src" , "tests" , "docs/conf.py" ]
@@ -113,7 +122,7 @@ def mypy(session: Session) -> None:
113
122
session .run ("mypy" , f"--python-executable={ sys .executable } " , "noxfile.py" )
114
123
115
124
116
- @nox . session (python = python_versions )
125
+ @session (python = python_versions )
117
126
def tests (session : Session ) -> None :
118
127
"""Run the test suite."""
119
128
session .install ("." )
@@ -125,7 +134,7 @@ def tests(session: Session) -> None:
125
134
session .notify ("coverage" )
126
135
127
136
128
- @nox . session
137
+ @session
129
138
def coverage (session : Session ) -> None :
130
139
"""Produce the coverage report."""
131
140
# Do not use session.posargs unless this is the only session.
@@ -140,15 +149,15 @@ def coverage(session: Session) -> None:
140
149
session .run ("coverage" , * args )
141
150
142
151
143
- @nox . session (python = python_versions )
152
+ @session (python = python_versions )
144
153
def typeguard (session : Session ) -> None :
145
154
"""Runtime type checking using Typeguard."""
146
155
session .install ("." )
147
156
session .install ("pytest" , "pytest-django" , "typeguard" , "pygments" )
148
157
session .run ("pytest" , f"--typeguard-packages={ package } " , * session .posargs )
149
158
150
159
151
- @nox . session (python = python_versions )
160
+ @session (python = python_versions )
152
161
def xdoctest (session : Session ) -> None :
153
162
"""Run examples with xdoctest."""
154
163
args = session .posargs or ["all" ]
@@ -157,7 +166,7 @@ def xdoctest(session: Session) -> None:
157
166
session .run ("python" , "-m" , "xdoctest" , package , * args )
158
167
159
168
160
- @nox . session (name = "docs-build" , python = "3.9" )
169
+ @session (name = "docs-build" , python = "3.9" )
161
170
def docs_build (session : Session ) -> None :
162
171
"""Build the documentation."""
163
172
args = session .posargs or ["docs" , "docs/_build" ]
@@ -171,7 +180,7 @@ def docs_build(session: Session) -> None:
171
180
session .run ("sphinx-build" , * args )
172
181
173
182
174
- @nox . session (python = "3.9" )
183
+ @session (python = "3.9" )
175
184
def docs (session : Session ) -> None :
176
185
"""Build and serve the documentation with live reloading on file changes."""
177
186
args = session .posargs or ["--open-browser" , "docs" , "docs/_build" ]
0 commit comments