1717import os
1818from pathlib import Path
1919import sys
20+ from typing import Callable , Dict , List , Optional
2021
2122import nox
2223
6566TEST_CONFIG .update (TEST_CONFIG_OVERRIDE )
6667
6768
68- def get_pytest_env_vars ():
69+ def get_pytest_env_vars () -> Dict [ str , str ] :
6970 """Returns a dict for pytest invocation."""
7071 ret = {}
7172
@@ -94,7 +95,7 @@ def get_pytest_env_vars():
9495#
9596
9697
97- def _determine_local_import_names (start_dir ) :
98+ def _determine_local_import_names (start_dir : str ) -> List [ str ] :
9899 """Determines all import names that should be considered "local".
99100
100101 This is used when running the linter to insure that import order is
@@ -132,7 +133,7 @@ def _determine_local_import_names(start_dir):
132133
133134
134135@nox .session
135- def lint (session ) :
136+ def lint (session : nox . sessions . Session ) -> None :
136137 if not TEST_CONFIG ["enforce_type_hints" ]:
137138 session .install ("flake8" , "flake8-import-order" )
138139 else :
@@ -153,7 +154,7 @@ def lint(session):
153154
154155
155156@nox .session
156- def blacken (session ) :
157+ def blacken (session : nox . sessions . Session ) -> None :
157158 session .install ("black" )
158159 python_files = [path for path in os .listdir ("." ) if path .endswith (".py" )]
159160
@@ -168,7 +169,9 @@ def blacken(session):
168169PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml" ]
169170
170171
171- def _session_tests (session , post_install = None ):
172+ def _session_tests (
173+ session : nox .sessions .Session , post_install : Callable = None
174+ ) -> None :
172175 """Runs py.test for a particular project."""
173176 if os .path .exists ("requirements.txt" ):
174177 session .install ("-r" , "requirements.txt" )
@@ -194,7 +197,7 @@ def _session_tests(session, post_install=None):
194197
195198
196199@nox .session (python = ALL_VERSIONS )
197- def py (session ) :
200+ def py (session : nox . sessions . Session ) -> None :
198201 """Runs py.test for a sample using the specified version of Python."""
199202 if session .python in TESTED_VERSIONS :
200203 _session_tests (session )
@@ -209,7 +212,7 @@ def py(session):
209212#
210213
211214
212- def _get_repo_root ():
215+ def _get_repo_root () -> Optional [ str ] :
213216 """ Returns the root folder of the project. """
214217 # Get root of this repository. Assume we don't have directories nested deeper than 10 items.
215218 p = Path (os .getcwd ())
@@ -232,7 +235,7 @@ def _get_repo_root():
232235
233236@nox .session
234237@nox .parametrize ("path" , GENERATED_READMES )
235- def readmegen (session , path ) :
238+ def readmegen (session : nox . sessions . Session , path : str ) -> None :
236239 """(Re-)generates the readme for a sample."""
237240 session .install ("jinja2" , "pyyaml" )
238241 dir_ = os .path .dirname (path )
0 commit comments