@@ -17,6 +17,7 @@ from __future__ import print_function
1717import os
1818from pathlib import Path
1919import sys
20+ from typing import Callable, Dict, List, Optional
2021
2122import nox
2223
@@ -68,7 +69,7 @@ except ImportError as e:
6869TEST_CONFIG.update(TEST_CONFIG_OVERRIDE)
6970
7071
71- def get_pytest_env_vars():
72+ def get_pytest_env_vars() -> Dict[str, str] :
7273 """Returns a dict for pytest invocation."""
7374 ret = {}
7475
@@ -97,7 +98,7 @@ INSTALL_LIBRARY_FROM_SOURCE = bool(os.environ.get("INSTALL_LIBRARY_FROM_SOURCE",
9798#
9899
99100
100- def _determine_local_import_names(start_dir) :
101+ def _determine_local_import_names(start_dir: str) -> List[str] :
101102 """Determines all import names that should be considered "local".
102103
103104 This is used when running the linter to insure that import order is
@@ -135,7 +136,7 @@ FLAKE8_COMMON_ARGS = [
135136
136137
137138@nox.session
138- def lint(session) :
139+ def lint(session: nox.sessions.Session) -> None :
139140 if not TEST_CONFIG['enforce_type_hints']:
140141 session.install("flake8", "flake8-import-order")
141142 else:
@@ -154,7 +155,7 @@ def lint(session):
154155
155156
156157@nox.session
157- def blacken(session) :
158+ def blacken(session: nox.sessions.Session) -> None :
158159 session.install("black")
159160 python_files = [path for path in os.listdir(".") if path.endswith(".py")]
160161
@@ -168,7 +169,7 @@ def blacken(session):
168169PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"]
169170
170171
171- def _session_tests(session, post_install= None):
172+ def _session_tests(session: nox.sessions.Session , post_install: Callable = None) -> None :
172173 """Runs py.test for a particular project."""
173174 if os.path.exists("requirements.txt"):
174175 session.install("-r", "requirements.txt")
@@ -194,7 +195,7 @@ def _session_tests(session, post_install=None):
194195
195196
196197@nox.session(python=ALL_VERSIONS)
197- def py(session) :
198+ def py(session: nox.sessions.Session) -> None :
198199 """Runs py.test for a sample using the specified version of Python."""
199200 if session.python in TESTED_VERSIONS:
200201 _session_tests(session)
@@ -209,7 +210,7 @@ def py(session):
209210#
210211
211212
212- def _get_repo_root():
213+ def _get_repo_root() -> Optional[str] :
213214 """ Returns the root folder of the project. """
214215 # Get root of this repository. Assume we don't have directories nested deeper than 10 items.
215216 p = Path(os.getcwd())
@@ -232,7 +233,7 @@ GENERATED_READMES = sorted([x for x in Path(".").rglob("*.rst.in")])
232233
233234@nox.session
234235@nox.parametrize("path", GENERATED_READMES)
235- def readmegen(session, path) :
236+ def readmegen(session: nox.sessions.Session , path: str) -> None :
236237 """(Re-)generates the readme for a sample."""
237238 session.install("jinja2", "pyyaml")
238239 dir_ = os.path.dirname(path)
0 commit comments