Skip to content

Conversation

@logan-nc
Copy link
Collaborator

@logan-nc logan-nc commented Jan 1, 2026

This branch adds a pre-commit yml file that cleans up the notebook meta data and outputs so we stop recording silly changes whenever anyone runs a notebook.

I made it a pre-commit so developers have to opt in by installing the pre-commit functionality and initializing it for their local repo. The alternative is to make it a hook, which would then be forced on anyone making any commit... I am open to thoughts on wether we should switch to this strict approach.

I also added a Julia Formatter. I think it would be valuable to enforce a standard of formatting, which makes the code more coherent and readable. I don't want to be overly prescriptive, but some consistent basics are good imo. I am also open to thoughts on this: should we add more prescriptions? Make it less prescriptive? Not use it?

logan-nc and others added 2 commits December 31, 2025 22:32
…file hygiene

Implements pre-commit configuration to prevent noisy Jupyter notebook commits
and maintain consistent file formatting across the repository.

Changes:
- Added .pre-commit-config.yaml with nbstripout and general file cleanup hooks
- Documented pre-commit setup in docs/src/set_up.md (developer-facing documentation)
- Added brief reference in CLAUDE.md pointing to proper documentation

The pre-commit hooks automatically:
- Strip Jupyter notebook outputs, execution counts, and metadata
- Remove trailing whitespace and fix line endings
- Validate YAML/TOML syntax
- Prevent accidentally committing large files (>5MB)

Note: Julia code formatting is handled separately via .JuliaFormatter.toml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Enables automatic Julia code formatting in pre-commit workflow now that
JuliaFormatter has been installed globally.

Changes:
- Added JuliaFormatter.jl hook to .pre-commit-config.yaml
- Updated docs/src/set_up.md with JuliaFormatter installation requirement

The JuliaFormatter hook formats Julia code according to .JuliaFormatter.toml
settings automatically on commit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@jhalpern30
Copy link
Collaborator

I made it a pre-commit so developers have to opt in by installing the pre-commit functionality and initializing it for their local repo. The alternative is to make it a hook, which would then be forced on anyone making any commit... I am open to thoughts on wether we should switch to this strict approach.

I am ok with it being a pre-commit. If someone commits a notebook with outputs still in it, it will be rather obvious during PR review and we can just mention to install the pre-commit package and run from there.

I also added a Julia Formatter. I think it would be valuable to enforce a standard of formatting, which makes the code more coherent and readable. I don't want to be overly prescriptive, but some consistent basics are good imo. I am also open to thoughts on this: should we add more prescriptions? Make it less prescriptive? Not use it?

I've been running it here and there on the repo, and I think we definitely need some sort of formatting, especially when it comes to whitespace removal, standardizing spacing in function calls, etc.. I've tried to remember when committing PRs but was not as diligent as I wanted and ended up committing changes that haven't been formatted and then not wanting to do an entirely separate PR to just do formatting, so I think auto-running this is a great idea. I think the requirement should just be to run the Julia formatter to catch bad formatting and not directly prescribe anything major that developers need to consider. This JuliaFormatter.toml file was directly copied from the FUSE repo in #40, and I think it works pretty well to clean up the code

@claude
Copy link

claude bot commented Jan 2, 2026

Code Review for PR #120: Add pre-commit hooks

Summary

This PR adds pre-commit hooks for notebook cleaning and Julia code formatting. The implementation is straightforward and will be useful for maintaining code consistency and reducing notebook noise in commits.

Code Quality & Best Practices

Strengths:

  • Documentation is clear and appropriately placed in developer-facing docs
  • Opt-in approach for pre-commit is sensible for developer tooling
  • The commit message format follows the repository's established conventions

Issues & Suggestions:

  1. Python version pinning (.pre-commit-config.yaml:7)

    • The config pins python3.10 but the setup docs don't specify this requirement
    • The GitHub Actions environment appears to use Python 3.12
    • Suggestion: Either change to python: python3 for flexibility, or document the Python 3.10 requirement
  2. Outdated pre-commit-hooks version (.pre-commit-config.yaml:25)

    • Using v4.5.0 from December 2023
    • Current version is v5.0.0+ (as of 2025)
    • Suggestion: Update to rev: v5.0.0 or later for bug fixes and improvements
  3. JuliaFormatter version (.pre-commit-config.yaml:44)

    • Using rev: v1.0.62 - verify this is current and update if needed
  4. Missing file type filtering for trailing-whitespace hook

    • The trailing-whitespace hook will run on all files by default
    • May cause issues with binary files or specific formats
  5. Potential hook order issue

    • nbstripout runs before end-of-file-fixer and trailing-whitespace
    • If nbstripout outputs without trailing newline, end-of-file-fixer modifies it
    • This creates potential commit loop
    • Suggestion: Test by running pre-commit run --all-files twice to ensure idempotency

Documentation Issues

  1. Inconsistent installation order (docs/src/set_up.md:193-194)

    • Docs show installing JuliaFormatter globally
    • The JuliaFormatter pre-commit hook downloads its own copy
    • Clarify if global installation is needed or remove this step
  2. Missing verification step

    • Add instructions showing pre-commit run --all-files as verification test

Testing Considerations

  • No test to verify hooks work correctly
  • No verification existing notebooks/code pass new rules
  • Before merging: run pre-commit run --all-files on entire codebase

Overall Assessment

The PR accomplishes its goals and is well-documented. Main issues: version mismatches, potential idempotency issues with hook ordering, and minor documentation clarity around JuliaFormatter installation.

Recommendation: Request changes to address Python version mismatch, update pre-commit-hooks version, and verify hook idempotency before merging.

Action Items:

  • Update pre-commit-hooks to v5.0.0+
  • Resolve Python version inconsistency
  • Test pre-commit run --all-files twice to ensure idempotency
  • Clarify or remove global JuliaFormatter installation requirement
  • Consider adding exclude patterns to avoid hook conflicts

@logan-nc logan-nc merged commit 0577fb1 into develop Jan 2, 2026
5 checks passed
@logan-nc logan-nc deleted the add_precommit branch January 2, 2026 19:13
@logan-nc
Copy link
Collaborator Author

logan-nc commented Jan 2, 2026

@matt-pharr @JaeBeom1019 @mfairborn23 @satelite2517 please consider initializing these precommits as per the instructions. it will be helpful if we all confirm to the same formatting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

architecture enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants