Skip to content

Add pre-commit config with linting for C++ and Python#121

Merged
JohanMabille merged 3 commits intomainfrom
precommit
Mar 16, 2026
Merged

Add pre-commit config with linting for C++ and Python#121
JohanMabille merged 3 commits intomainfrom
precommit

Conversation

@ianthomas23
Copy link
Member

This adds linting of C++ and Python via pre-commit, fixing #1.

Configuration is taken from a combination of sparrow and mamba.

  • clang-format for C++ is from sparrow with the sparrow-specific import order removed, I've taken this as an example of recent good practice and I am not particularly concerned by exactly which rules we do and do follow, along as there are some rules that are enforced. We can bikeshed if anyone wants to 😃.
  • Remainder of .pre-commit-config.yaml is a subset of those from mamba to enforce some generic checks plus Python linting via pyupgrade and ruff.
  • There are a few ruff settings in a new pyproject.toml. It is a little strange to have a pyproject.toml in a non-Python project, but this is a common place for such tools to look for configuration settings.

I've added pre-commit as a new dev dependency in the two micromamba environment files - maintainers should update their environments accordingly. When this is done pre-commit will be automatically run on commits, and can be manually run using

pre-commit run --all-files

pre-commit.ci should automatically run in CI on PRs to identify and fix problems, we will have to see if it works. If/when it does, there will be a lot of changes to pretty much all of the C++ and Python files as part of this PR.

There is no linting of JavaScript/TypeScript yet as there are only a couple of TypeScript files in the wasm testing only.

@ianthomas23
Copy link
Member Author

pre-commit.ci did kick in and correct about 1000 lines of code!

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 88.07339% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.23%. Comparing base (ade2c75) to head (b5fa4dd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/utils/common.cpp 30.00% 14 Missing ⚠️
src/subcommand/status_subcommand.cpp 76.47% 12 Missing ⚠️
src/subcommand/merge_subcommand.cpp 84.37% 10 Missing ⚠️
src/subcommand/diff_subcommand.cpp 90.78% 7 Missing ⚠️
src/subcommand/tag_subcommand.cpp 82.85% 6 Missing ⚠️
src/wrapper/repository_wrapper.cpp 64.70% 6 Missing ⚠️
src/utils/progress.cpp 84.61% 2 Missing ⚠️
src/subcommand/checkout_subcommand.cpp 88.88% 1 Missing ⚠️
src/subcommand/init_subcommand.cpp 90.90% 1 Missing ⚠️
src/subcommand/log_subcommand.cpp 97.56% 1 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
+ Coverage   87.98%   88.23%   +0.25%     
==========================================
  Files          60       60              
  Lines        2489     2619     +130     
  Branches      308      309       +1     
==========================================
+ Hits         2190     2311     +121     
- Misses        299      308       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JohanMabille JohanMabille merged commit d9fe9e4 into main Mar 16, 2026
7 checks passed
@JohanMabille JohanMabille deleted the precommit branch March 16, 2026 17:00
@ianthomas23 ianthomas23 mentioned this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants