From 08dea2348b2c90ed5636af5880491196bf6ed9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Thu, 6 Jun 2024 09:31:27 +0200 Subject: [PATCH] Add more ignoredirs (#39) --- .pre-commit-config.yaml | 4 ++-- src/clean_notebook/clean.py | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 17cde1d..da058f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: check-json - id: check-executables-have-shebangs - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.4.5 + rev: v0.4.8 hooks: - id: ruff - id: ruff-format @@ -26,7 +26,7 @@ repos: additional_dependencies: - tomli - repo: https://github.com/hoxbro/prettier-pre-commit - rev: v3.2.5 + rev: v3.3.1 hooks: - id: prettier types_or: diff --git a/src/clean_notebook/clean.py b/src/clean_notebook/clean.py index 2110aad..3497a45 100644 --- a/src/clean_notebook/clean.py +++ b/src/clean_notebook/clean.py @@ -7,6 +7,8 @@ __all__ = ("clean_notebook", "clean_single_notebook") +IGNOREDIRS = (".venv", ".pixi", "site-packages", ".ipynb_checkpoints") + def clean_notebook( paths: list[str | Path], @@ -86,9 +88,12 @@ def _get_files(paths: list[str | Path]) -> Iterator[Path]: if path.is_file() and path.suffix == ".ipynb": yield path if path.is_dir(): + if path.name in IGNOREDIRS: + continue for file in path.rglob("*.ipynb"): - if file.parent.name != ".ipynb_checkpoints": - yield file + if any(ps in IGNOREDIRS for ps in file.parts): + continue + yield file def _ignore(cell: dict[str, Any], ignore: list[str] | None) -> dict[str, Any]: