17
17
import os
18
18
from pathlib import Path
19
19
import sys
20
+ from typing import Callable , Dict , List , Optional
20
21
21
22
import nox
22
23
68
69
TEST_CONFIG .update (TEST_CONFIG_OVERRIDE )
69
70
70
71
71
- def get_pytest_env_vars ():
72
+ def get_pytest_env_vars () -> Dict [ str , str ] :
72
73
"""Returns a dict for pytest invocation."""
73
74
ret = {}
74
75
@@ -97,7 +98,7 @@ def get_pytest_env_vars():
97
98
#
98
99
99
100
100
- def _determine_local_import_names (start_dir ) :
101
+ def _determine_local_import_names (start_dir : str ) -> List [ str ] :
101
102
"""Determines all import names that should be considered "local".
102
103
103
104
This is used when running the linter to insure that import order is
@@ -135,7 +136,7 @@ def _determine_local_import_names(start_dir):
135
136
136
137
137
138
@nox .session
138
- def lint (session ) :
139
+ def lint (session : nox . sessions . Session ) -> None :
139
140
if not TEST_CONFIG ['enforce_type_hints' ]:
140
141
session .install ("flake8" , "flake8-import-order" )
141
142
else :
@@ -154,7 +155,7 @@ def lint(session):
154
155
155
156
156
157
@nox .session
157
- def blacken (session ) :
158
+ def blacken (session : nox . sessions . Session ) -> None :
158
159
session .install ("black" )
159
160
python_files = [path for path in os .listdir ("." ) if path .endswith (".py" )]
160
161
@@ -168,7 +169,7 @@ def blacken(session):
168
169
PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml" ]
169
170
170
171
171
- def _session_tests (session , post_install = None ):
172
+ def _session_tests (session : nox . sessions . Session , post_install : Callable = None ) -> None :
172
173
"""Runs py.test for a particular project."""
173
174
if os .path .exists ("requirements.txt" ):
174
175
session .install ("-r" , "requirements.txt" )
@@ -194,7 +195,7 @@ def _session_tests(session, post_install=None):
194
195
195
196
196
197
@nox .session (python = ALL_VERSIONS )
197
- def py (session ) :
198
+ def py (session : nox . sessions . Session ) -> None :
198
199
"""Runs py.test for a sample using the specified version of Python."""
199
200
if session .python in TESTED_VERSIONS :
200
201
_session_tests (session )
@@ -209,7 +210,7 @@ def py(session):
209
210
#
210
211
211
212
212
- def _get_repo_root ():
213
+ def _get_repo_root () -> Optional [ str ] :
213
214
""" Returns the root folder of the project. """
214
215
# Get root of this repository. Assume we don't have directories nested deeper than 10 items.
215
216
p = Path (os .getcwd ())
@@ -232,7 +233,7 @@ def _get_repo_root():
232
233
233
234
@nox .session
234
235
@nox .parametrize ("path" , GENERATED_READMES )
235
- def readmegen (session , path ) :
236
+ def readmegen (session : nox . sessions . Session , path : str ) -> None :
236
237
"""(Re-)generates the readme for a sample."""
237
238
session .install ("jinja2" , "pyyaml" )
238
239
dir_ = os .path .dirname (path )
0 commit comments