1
- """project_name Nox sessions."""
2
-
3
- import tempfile
4
- from typing import Any
1
+ """{{cookiecutter.project_name}} Nox sessions."""
5
2
6
3
import nox
7
4
from nox .sessions import Session
8
5
9
6
locations = "src" , "tests" , "noxfile.py" , "docs/conf.py"
10
7
nox .options .sessions = "lint" , "mypy" , "pytype" , "tests"
11
- _versions = ["3.7" ]
12
-
13
-
14
- def install_with_constraints (session : Session , * args : str , ** kwargs : Any ) -> None :
15
- """Install application dependencies using constraints."""
16
- with tempfile .NamedTemporaryFile () as requirements :
17
- session .run (
18
- "poetry" ,
19
- "export" ,
20
- "--dev" ,
21
- "--format=requirements.txt" ,
22
- f"--output={ requirements .name } " ,
23
- external = True ,
24
- )
25
- session .install (f"--constraint={ requirements .name } " , * args , ** kwargs )
8
+ _versions = ["3.7" , "3.8" ]
26
9
27
10
28
11
@nox .session (python = _versions )
29
12
def lint (session : Session ) -> None :
30
13
"""Run the code linters."""
31
14
args = session .posargs or locations
32
- install_with_constraints (
33
- session ,
15
+ session . install (
16
+ "darglint" ,
34
17
"flake8" ,
35
18
"flake8-annotations" ,
36
19
"flake8-black" ,
37
- "flake8-isort" ,
38
20
"flake8-docstrings" ,
39
- "darglint" ,
21
+ "flake8-isort" ,
22
+ "flake8-rst-docstrings" ,
23
+ "flake8_sphinx_links" ,
40
24
)
41
25
session .run ("flake8" , * args )
42
26
@@ -46,9 +30,7 @@ def tests(session: Session) -> None:
46
30
"""Run tests."""
47
31
args = session .posargs or ["--cov" , "--xdoctest" ]
48
32
session .run ("poetry" , "install" , "--no-dev" , external = True )
49
- install_with_constraints (
50
- session , "coverage[toml]" , "pytest" , "pytest-cov" , "xdoctest"
51
- )
33
+ session .install ("coverage[toml]" , "pytest" , "pytest-cov" , "xdoctest" )
52
34
session .run ("pytest" , * args )
53
35
54
36
@@ -63,37 +45,37 @@ def format(session: Session) -> None:
63
45
def isort (session : Session ) -> None :
64
46
"""Run the import re-orderer (isort)."""
65
47
args = session .posargs or locations
66
- install_with_constraints ( session , "flake8-isort" )
48
+ session . install ( "flake8-isort" )
67
49
session .run ("isort" , * args )
68
50
69
51
70
52
@nox .session (python = _versions )
71
53
def black (session : Session ) -> None :
72
54
"""Run the code reformatter (black)."""
73
55
args = session .posargs or locations
74
- install_with_constraints ( session , "black" )
56
+ session . install ( "black" )
75
57
session .run ("black" , * args )
76
58
77
59
78
60
@nox .session (python = _versions )
79
61
def mypy (session : Session ) -> None :
80
62
"""Run the static type checker (mypy))."""
81
63
args = session .posargs or locations
82
- install_with_constraints ( session , "mypy" )
64
+ session . install ( "mypy" )
83
65
session .run ("mypy" , * args )
84
66
85
67
86
68
@nox .session (python = _versions )
87
69
def pytype (session : Session ) -> None :
88
70
"""Run the static type checker (pytype)."""
89
71
args = session .posargs or ["--disable=import-error" , * locations ]
90
- install_with_constraints ( session , "pytype" )
72
+ session . install ( "pytype" )
91
73
session .run ("pytype" , * args )
92
74
93
75
94
76
@nox .session (python = _versions )
95
77
def docs (session : Session ) -> None :
96
78
"""Build the documentation."""
97
79
session .run ("poetry" , "install" , "--no-dev" , external = True )
98
- install_with_constraints ( session , "sphinx" , "sphinx-autodoc-typehints" )
80
+ session . install ( "sphinx" , "sphinx-autodoc-typehints" )
99
81
session .run ("sphinx-build" , "docs" , "docs/_build" )
0 commit comments