Add type hints for noxfile.py
MODIFY
noxfile.py
noxfile.py
@@ -14,7 +14,7 @@ SOURCE_FILES = [
]
-def tests_impl(session, extras="socks,secure,brotli"):
+def tests_impl(session: nox.Session, extras: str = "socks,secure,brotli") -> None:
# Install deps and the package itself.
session.install("-r", "dev-requirements.txt")
session.install(f".[{extras}]")
@@ -51,12 +51,12 @@ def tests_impl(session, extras="socks,secure,brotli"):
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "pypy"])
-def test(session):
+def test(session: nox.Session) -> None:
tests_impl(session)
@nox.session(python=["2.7"])
-def unsupported_python2(session):
+def unsupported_python2(session: nox.Session) -> None:
# Can't check both returncode and output with session.run
process = subprocess.run(
["python", "setup.py", "install"],
@@ -70,7 +70,7 @@ def unsupported_python2(session):
@nox.session(python=["3"])
-def test_brotlipy(session):
+def test_brotlipy(session: nox.Session) -> None:
"""Check that if 'brotlipy' is installed instead of 'brotli' or
'brotlicffi' that we still don't blow up.
"""
@@ -78,12 +78,12 @@ def test_brotlipy(session):
tests_impl(session, extras="socks,secure")
-def git_clone(session, git_url):
+def git_clone(session: nox.Session, git_url: str) -> None:
session.run("git", "clone", "--depth", "1", git_url, external=True)
@nox.session()
-def downstream_botocore(session):
+def downstream_botocore(session: nox.Session) -> None:
root = os.getcwd()
tmp_dir = session.create_tmp()
@@ -102,7 +102,7 @@ def downstream_botocore(session):
@nox.session()
-def downstream_requests(session):
+def downstream_requests(session: nox.Session) -> None:
root = os.getcwd()
tmp_dir = session.create_tmp()
@@ -123,7 +123,7 @@ def downstream_requests(session):
@nox.session()
-def format(session):
+def format(session: nox.Session) -> None:
"""Run code formatters."""
session.install("pre-commit")
session.run("pre-commit", "--version")
@@ -142,7 +142,7 @@ def format(session):
@nox.session
-def lint(session):
+def lint(session: nox.Session) -> None:
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files")
@@ -150,19 +150,20 @@ def lint(session):
@nox.session(python="3.8")
-def mypy(session):
+def mypy(session: nox.Session) -> None:
"""Run mypy."""
session.install("mypy==0.910")
session.install("idna>=2.0.0")
session.install("cryptography>=1.3.4")
session.install("tornado>=6.1")
session.install("pytest>=6.2")
+ session.install("nox")
session.run("mypy", "--version")
- session.run("mypy", "src/urllib3", "dummyserver")
+ session.run("mypy", "src/urllib3", "dummyserver", "noxfile.py")
@nox.session
-def docs(session):
+def docs(session: nox.Session) -> None:
session.install("-r", "docs/requirements.txt")
session.install(".[socks,secure,brotli]")

Add type hints for noxfile.py