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

CI: Update pre-commit hooks #6367

Merged
merged 2 commits into from
Apr 23, 2024
Merged

Conversation

danielhollas
Copy link
Collaborator

@danielhollas danielhollas commented Apr 22, 2024

A smattering of small updates to pre-commit hooks and pre-commit workflow in ci-style.yml
(partly overlapping with #6368)

  • ran pre-commit autoupdate

  • remove flynt linter, according to this ruff issue, most of it is already implemented in ruff, with the exception of FLY001 (consider replacing string concatenation with f-string).

     -tc, --transform-concats`
                      Replace string concatenations (defined as +
                      operations involving string literals) with
                      f-strings. Available only if flynt is
                      installed with 3.8+ interpreter.
    

If this is deemed important enough I can revert this change.

  • Don't install unneeded system dependencies in pre-commit run (done in Devops: Install from abstract dependencies for pre-commit CI #6368 as well)
  • Run pre-commit with python 3.11 instead of 3.10. I was hoping to get some decent speedup from this, but it looks like only several seconds, likely because most of the time is spent installing / bulding pre-commit dependencies.

@danielhollas danielhollas marked this pull request as ready for review April 22, 2024 23:29
@danielhollas danielhollas requested a review from sphuber April 22, 2024 23:42
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks @danielhollas

remove flynt linter, according to astral-sh/ruff#2102, most of it is already implemented in ruff, with the exception of FLY001 (consider replacing string concatenation with f-string).

I would like to have just ruff, but until it completely replaces it, let's keep flynt for the time being. Also, as a sidenote, I think you should have enabled its rules explicitly in the pyproject.toml. Don't think they are enabled by default

run pre-commit autoupdate

Don't think you have done this. But just as well. I removed it at some point because I found it obnoxious. A lot of updates where often nothing was changed. I just manually updated it once before each release. Works fine.

@danielhollas
Copy link
Collaborator Author

danielhollas commented Apr 23, 2024

Also, as a sidenote, I think you should have enabled its rules explicitly in the pyproject.toml. Don't think they are enabled by default

Ah, you're right. I tried enabling FLY002 and running with --unsafe-fixes and tbh I find most of the fixes rather unhelpful, consider

-    user_input = '\n'.join(
-        ['yes', aiida_localhost.label, label, label_unique, 'd', 'core.arithmetic.add', '/bin/bash', 'y']
-    )
+    user_input = f'yes\n{aiida_localhost.label}\n{label}\n{label_unique}\nd\ncore.arithmetic.add\n/bin/bash\ny'

btw: Also tried enabling UP fixes and that resulted in a lot of churn, so we couldn't enable it easily anyway.

Don't think you have done this. But just as well. I removed it at some point because I found it obnoxious. A lot of updates where often nothing was changed. I just manually updated it once before each release. Works fine.

Nah-uh, I did! 😛 I meant to use the past tense, what I meant is I ran it manually.
Also, btw I am not sure what you mean, since the autoupdate is still run quaterly per .pre-commit-config.yaml

ci:
  autofix_prs: true
  autoupdate_commit_msg: 'Devops: Update pre-commit dependencies'
  autoupdate_schedule: quarterly
  skip: [mypy, dm-generate-all, dependencies, verdi-autodocs]

Well, the remnants of this PR are a bit sad, up to you if you still want to merge this. Sorry for the churn.

@danielhollas danielhollas requested a review from sphuber April 23, 2024 08:13
@sphuber
Copy link
Contributor

sphuber commented Apr 23, 2024

Nah-uh, I did! 😛 I meant to use the past tense, what I meant is I ran it manually.
Also, btw I am not sure what you mean, since the autoupdate is still run quaterly per .pre-commit-config.yaml

Ah yeah, that is only because I don't think it allows to turn off entirely. And still wanted to keep the functionality of it running pre-commit on PRs, just because some contributors don't have it enabled locally.

Well, the remnants of this PR are a bit sad, up to you if you still want to merge this. Sorry for the churn.

I will keep it and merge it. As mentioned, I was anyway going to do this soon for the upcoming release, and ruff 0.4.0 comes with further performance improvements

@sphuber sphuber merged commit 3dda84f into aiidateam:main Apr 23, 2024
19 checks passed
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.

2 participants