Skip to content

Commit

Permalink
noxfile and mypy.ini
Browse files Browse the repository at this point in the history
- check subdirs separately (python/mypy#4008)
- use mypy flags --install-types --non-interactive
- fixup noxfile: use lint_plugins to run mypy on plugins
- noxfile: run mypy on tools/ without --strict flag
  • Loading branch information
Jasha10 committed Feb 14, 2022
1 parent e7816cc commit 27bd6fc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[mypy]
python_version = 3.6
mypy_path=.stubs
exclude = (?x)(
build/
| ^hydra/grammar/gen/
)

[mypy-antlr4.*]
ignore_missing_imports = True
Expand Down
46 changes: 41 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,55 @@ def lint(session):

session.run(*isort, silent=SILENT)

session.run("mypy", ".", "--strict", silent=SILENT)
session.run(
"mypy",
".",
"--strict",
"--install-types",
"--non-interactive",
"--exclude=^examples/",
"--exclude=^tests/standalone_apps/",
"--exclude=^tests/test_apps/",
"--exclude=^tools/",
"--exclude=^plugins/",
silent=SILENT,
)
session.run("flake8", "--config", ".flake8")
session.run("yamllint", "--strict", ".")

example_dirs = [
mypy_check_subdirs = [
"examples/advanced",
"examples/configure_hydra",
"examples/patterns",
"examples/instantiate",
"examples/tutorials/basic/your_first_hydra_app",
"examples/tutorials/basic/running_your_hydra_app",
"examples/tutorials/structured_configs",
"tests/standalone_apps",
"tests/test_apps",
]
for edir in example_dirs:
dirs = find_dirs(path=edir)
for sdir in mypy_check_subdirs:
dirs = find_dirs(path=sdir)
for d in dirs:
session.run("mypy", d, "--strict", silent=SILENT)
session.run(
"mypy",
d,
"--strict",
"--install-types",
"--non-interactive",
silent=SILENT,
)

for sdir in ["tools"]: # no --strict flag for tools
dirs = find_dirs(path=sdir)
for d in dirs:
session.run(
"mypy",
d,
"--install-types",
"--non-interactive",
silent=SILENT,
)

# lint example plugins
lint_plugins_in_dir(session=session, directory="examples/plugins")
Expand Down Expand Up @@ -295,6 +327,8 @@ def lint_plugins_in_dir(session, directory: str) -> None:
session.run(
"mypy",
"--strict",
"--install-types",
"--non-interactive",
f"{path}/hydra_plugins",
"--config-file",
f"{BASE}/.mypy.ini",
Expand All @@ -303,6 +337,8 @@ def lint_plugins_in_dir(session, directory: str) -> None:
session.run(
"mypy",
"--strict",
"--install-types",
"--non-interactive",
"--namespace-packages",
"--config-file",
f"{BASE}/.mypy.ini",
Expand Down

0 comments on commit 27bd6fc

Please sign in to comment.