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

use pre-commit for python files #59522

Merged
merged 8 commits into from
Nov 29, 2024
Merged

use pre-commit for python files #59522

merged 8 commits into from
Nov 29, 2024

Conversation

3nids
Copy link
Member

@3nids 3nids commented Nov 20, 2024

This enables pre-commit hook for Python files and disable Python formatting from prepare-commit.sh

I've only added: pyupgrade, black and isort without specific config for the sake of simplicity/clarity. See config for details.

I've also enabled auto-fix for PRs (will be effective when we activate pre-commit.ci).

We've recently succeeded at using clang-format on a sipified project (see kadas-albireo/kadas-albireo2#175). So this is a first small step before starting to touch at cpp code.

@github-actions github-actions bot added this to the 3.42.0 milestone Nov 20, 2024
Copy link

github-actions bot commented Nov 20, 2024

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 88c687e)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 88c687e)

@3nids
Copy link
Member Author

3nids commented Nov 20, 2024

@troopa81 @nyalldawson @elpaso @m-kuhn any feedback welcome!


ci:
autofix_prs: true
autoupdate_schedule: quarterly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that mean that if you're the first to push a PR after a hook update (let's say black rules for instance), you're gonna push a lot of modified files which are not related to your PR? Or is there an auto PR/commit pushed automatically on the repo on update?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoupdate is to update the tools used, so nothing related to the source code.

if there's a hook update, there's not that many changes brought. And in a PR, IIRC only the modified files are tested.

@m-kuhn
Copy link
Member

m-kuhn commented Nov 20, 2024

I am a big fan of pre-commit and supportive of actions to move there (I even tried to launch an unsuccessful crowdfunding campaign to sponsor @elpaso 's QEP). I also like black. I did not review the changes or configuration yet.

The main question here for me is, how this coexists with existing pre-commit hooks, in terms of local development configuration? Does one call the other (pre-commit the existing prepare_commit.sh or vice versa) or can the system be configured to run both in a different way)?

@nyalldawson
Copy link
Collaborator

Can you create a .git-blame-ignore-revs file and exclude the "run-precommit" commit from it? See https://gist.github.com/kateinoigakukun/b0bc920e587851bfffa98b9e279175f2

And I'm hugely in favour of this move!

@3nids
Copy link
Member Author

3nids commented Nov 21, 2024

how this coexists with existing pre-commit hooks

good point, I've added prepare_commit to the pre-commit hook: f24de2e

Can you create a .git-blame-ignore-revs file and exclude the "run-precommit" commit from it?

good catch. I've added the file. I suppose we can wait to merge to update that file with the proper commit (in case it's rebased)?

@3nids

This comment was marked as outdated.

@3nids
Copy link
Member Author

3nids commented Nov 22, 2024

In case there is no further discussions, I would merge it in a couple of days.

I would assume the general acceptance is fine since there were no objections in @elpaso's QEP qgis/QGIS-Enhancement-Proposals#265

Copy link
Member

@m-kuhn m-kuhn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections so far but positive feedback. I'm in favor of merging this.

@3nids 3nids merged commit 0f032e5 into qgis:master Nov 29, 2024
28 of 29 checks passed
@3nids 3nids deleted the pre-commit-python branch November 29, 2024 14:38
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