srstevenson / nb-clean

Clean Jupyter notebooks for version control. Remove metadata, outputs, and execution counts with Git and pre-commit support.
https://pypi.org/project/nb-clean
ISC License
137 stars 19 forks source link

Request: `pyproject.toml`-based configuration #259

Closed jamesbraza closed 7 months ago

jamesbraza commented 7 months ago

I currently use nb-clean in my pre-commit config like so:

---
default_language_version:
    python: python3

repos:
    - repo: https://github.com/srstevenson/nb-clean
      rev: 3.2.0
      hooks:
          - id: nb-clean
            args: [--preserve-cell-outputs, --remove-empty-cells]

It would be nice if the args could be moved to a pyproject.toml, so that running nb-clean clean locally (outside of pre-commit) could also use the same configuration.

srstevenson commented 7 months ago

I'm not eager to add configuration file parsing because of the additional complexity it would bring (such as dealing with overrides from command line arguments), especially as this is not a codebase I work on regularly. You can run the pre-commit hook manually with pre-commit run nb-clean --all-files; does that suffice for your use case?

jamesbraza commented 7 months ago

Yeah that's a fine workaround, so feel free to close this out.

I will say though, it's not a big lift. CLI args always override the associated config file entry, and this simple conditional logic would live outside of the core of nb-clean.