Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more ignoredirs #39

Merged
merged 3 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading