Lint the notebooks in the lint session
Only `ruff` checks them because the formatters would rewrite the cells. The per-file ignores fit exploratory code that is never rerun.
This commit is contained in:
parent
a06cb5bdfb
commit
7a000145a7
2 changed files with 15 additions and 1 deletions
|
|
@ -97,6 +97,9 @@ PACKAGE_LOCATION = "src/"
|
|||
DOCS_BUILD = ".cache/docs/"
|
||||
DOCS_LOCATION = "docs/"
|
||||
|
||||
# Only `ruff` lints the notebooks because the formatters would rewrite them
|
||||
NOTEBOOKS_LOCATION = "research/"
|
||||
|
||||
SCRIPTS_LOCATION = "scripts/"
|
||||
|
||||
TESTS_LOCATION = "tests/"
|
||||
|
|
@ -266,6 +269,8 @@ def lint_code(session: nox.Session) -> None:
|
|||
# Interpret extra arguments as `locations` of source files
|
||||
locations = session.posargs or SRC_LOCATIONS
|
||||
|
||||
ruff_locations = session.posargs or (*SRC_LOCATIONS, NOTEBOOKS_LOCATION)
|
||||
|
||||
# `flake8` reads the "[tool.flake8]" section in pyproject.toml
|
||||
# only with the `flake8-pyproject` plugin installed
|
||||
session.run("flake8", "--version")
|
||||
|
|
@ -275,7 +280,7 @@ def lint_code(session: nox.Session) -> None:
|
|||
session.run("isort", "--check-only", *locations)
|
||||
|
||||
session.run("ruff", "--version")
|
||||
session.run("ruff", "check", *locations)
|
||||
session.run("ruff", "check", *ruff_locations)
|
||||
|
||||
session.run("mypy", "--version")
|
||||
session.run("mypy", *TYPECHECK_LOCATIONS)
|
||||
|
|
|
|||
|
|
@ -735,6 +735,15 @@ external = [
|
|||
"migrations/versions/*.py" = ["ANN0", "ANN2", "S608"]
|
||||
# Type annotations are not strictly enforced
|
||||
"noxfile.py" = ["ANN0", "ANN2"]
|
||||
"research/*.ipynb" = [
|
||||
"ANN0", "ANN2", # Type annotations are not strictly enforced
|
||||
"E501", # Exploratory cells read better unwrapped
|
||||
"E712", # `== True` filters `pandas` columns element-wise
|
||||
"PTH", # Paths stay `str`s as in the stored outputs
|
||||
"S101", # `assert` statements document expectations
|
||||
"S605", "S608", # No untrusted input
|
||||
"T20", # `print()` shows results
|
||||
]
|
||||
# `print()` is ok in ad-hoc scripts
|
||||
"scripts/**" = ["T20"]
|
||||
# - ANN0, ANN2 => Type annotations are not strictly enforced
|
||||
|
|
|
|||
Loading…
Reference in a new issue