diff --git a/noxfile.py b/noxfile.py index cd577df..8a4b435 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 791833d..23469bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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