Skip to content

Add a minimal pre-commit config with ruff#152

Merged
bdraco merged 21 commits intomasterfrom
pre-commit
May 17, 2025
Merged

Add a minimal pre-commit config with ruff#152
bdraco merged 21 commits intomasterfrom
pre-commit

Conversation

@bdraco
Copy link
Member

@bdraco bdraco commented May 8, 2025

Leaving this unmerged because I'm not sure how everyone feels about using ruff

I'll add the format check to the CI in a followup if this is OK with everyone.

@codecov
Copy link

codecov bot commented May 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.85%. Comparing base (924b981) to head (97843d3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
- Coverage   93.91%   93.85%   -0.07%     
==========================================
  Files           3        3              
  Lines         378      374       -4     
  Branches       29       29              
==========================================
- Hits          355      351       -4     
  Misses         14       14              
  Partials        9        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.

@bdraco
Copy link
Member Author

bdraco commented May 8, 2025

Just realized we don't test on 3.13

Let me fix that first

@bdraco bdraco marked this pull request as ready for review May 8, 2025 19:51
@saghul
Copy link
Contributor

saghul commented May 8, 2025

😱 no double quotes everywhere please

@Dreamsorcerer
Copy link
Member

😱 no double quotes everywhere please

Looks to me like most of the code is already double quotes, so that'd just make it consistent across the codebase. Also easier to become compatible with formatters which all default to double quotes.

@bdraco
Copy link
Member Author

bdraco commented May 8, 2025

I reconfigured ruff to use single quotes

@Dreamsorcerer
Copy link
Member

Yeah, that seems to be a lot more changes than double quotes. Would be preferable to me to follow the org-wide consensus of double quotes.

@webknjaz
Copy link
Member

I'm not sure sure there's a concensus. I personally prefer the single ones 🤷‍♂️

@webknjaz
Copy link
Member

Also, formatting YAML with indents like that will lead to synching complications.

@webknjaz
Copy link
Member

Oh, and when formatting, I recommend separating linting fixes from style formatting as the latter could be added to blame ignore while the former shouldn't be hidden. In general, smaller changes are easier to review and agree on.

@webknjaz
Copy link
Member

I'm pretty sure commitizen can be irritating too. Particularly, because it seems to enforce prefixed commit titles that are at odds with best practices (gitlint) and reinforce bad changelog hygiene..

@webknjaz
Copy link
Member

I was integrating Ruff in a couple of places recently. I've found it useful to run the linter with --statistics manually at first. Then --select with --fix for a number of most common violations, committing each separately. Then, I only added it in linting mode (+config with linting and temporary suppressions). And finally I was adding the formatter but I wanted better trailing commas which sometimes canceled out Ruff. I've settled on a double-run of ruff with add-trailing-commas in-between and the outcome was rather good.

@bdraco
Copy link
Member Author

bdraco commented May 12, 2025

I trimmed down the config significantly and reverted the YAML changes.

I don't have strong preferences for the code formatting settings. As long as it's automated and I don't have to think about it, I'm good with whatever the group decides.

@bdraco bdraco changed the title Add a basic pre-commit config with ruff Add a minimal pre-commit config with ruff May 12, 2025
@webknjaz
Copy link
Member

Could you separate pure formatting from everything else, though? This needs a separate PR so that we could get a commit hash for blame ignore. Just make sure it's only formatting and not linting fixes or anything else.

@webknjaz
Copy link
Member

Also, the ruff entries should go first in the pre-commit config because other linters should check the changed versions of files after they've been formatted.

bdraco added a commit that referenced this pull request May 12, 2025
This PR focuses on reformatting the codebase and normalizing end-of-line characters. It was separated from #152 to allow us to add the merge SHA of this PR to the list of exclusions for GitHub diffs once it's squashed and merged.
@bdraco
Copy link
Member Author

bdraco commented May 12, 2025

formatting moved to #155

@bdraco
Copy link
Member Author

bdraco commented May 17, 2025

This is a good start. We can expand this later

@bdraco bdraco merged commit c7a5c24 into master May 17, 2025
21 checks passed
@bdraco bdraco deleted the pre-commit branch May 17, 2025 18:51
@bdraco bdraco mentioned this pull request Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants