Skip to content

Commit

Permalink
Add more ignoredirs (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Jun 6, 2024
1 parent 9cf8ef2 commit 08dea23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions src/clean_notebook/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

__all__ = ("clean_notebook", "clean_single_notebook")

IGNOREDIRS = (".venv", ".pixi", "site-packages", ".ipynb_checkpoints")


def clean_notebook(
paths: list[str | Path],
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit 08dea23

Please sign in to comment.