Skip to content

Pre-commit update#36

Merged
mbercx merged 3 commits intoaiidateam:mainfrom
danielhollas:pre-commit-update
Oct 1, 2025
Merged

Pre-commit update#36
mbercx merged 3 commits intoaiidateam:mainfrom
danielhollas:pre-commit-update

Conversation

@danielhollas
Copy link
Collaborator

@danielhollas danielhollas commented Sep 30, 2025

  • Use ruff for both linting and formatting (added ruff config from aiida-core)
  • Remove unused py dependency (used only in disabled conda support, and also is deprecated)

New version of #31

"types-pyyaml~=6.0",
]

[dependency-groups]
Copy link
Collaborator Author

@danielhollas danielhollas Sep 30, 2025

Choose a reason for hiding this comment

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

This makes development with uv easier since uv installs dev dependency group by default.

So e.g. one can run uv run pytest straight after cloning a repo and it will work.

For a general info about the (new) concept of "dependency groups" see PEP-735.

In principle this should obviate the need for the dev extras. The only disadvantage is that the dependency group is a very new thing and would not work with older pip (or other installation managers) versions.

(feel free to split this comment into a separate commit :-) )

Copy link
Member

Choose a reason for hiding this comment

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

Haha, well, if you insist! 😉

Thanks for the note on "dependency groups"! Always good to read a PEP in the morning.

mbercx and others added 2 commits October 1, 2025 08:00
The `py` dependency was using in the (currently disabled) `CondaProject` implementation.
Since we'll most likely not rely on this package when we reintroduce support for
`conda`, we can remove it from the dependencies list.

Co-authored-by: Daniel Hollas <daniel.hollas@bristol.ac.uk>
Add a `dev` dependency group, see PEP735 for more information on the concept:

https://peps.python.org/pep-0735/

Besides the advantages described in PEP735, adding a `dev` dependency group makes
development with `uv` easier since `uv` installs the `dev` dependency group by default.
Now one can run `uv run pytest` straight after cloning a repo and it will work.

In the future this will the remove the need for the `dev` extras. However, dependency
groups are very new, and only supported from `pip` v25.1 via the `--group` option:

    pip install -e. --group dev

Co-authored-by: Daniel Hollas <daniel.hollas@bristol.ac.uk>
@mbercx mbercx force-pushed the pre-commit-update branch 2 times, most recently from d299f23 to c6fffd3 Compare September 30, 2025 22:09
Copy link
Member

@mbercx mbercx left a comment

Choose a reason for hiding this comment

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

Thanks a million @danielhollas! I'm not going to bike shed about which rules we select, since we apparently were selecting none before (see my comment 🙈).

I reorganized the commits as you suggested, and left one suggestion for cleaning up the .pre-commit-config.yaml some more. I'd also squash all pre-commit related changes into one commit, if that's ok?

@@ -18,26 +18,12 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need these old hooks when we switch to Ruff? I think we can also remove the exclude above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are still useful for non-python files, but it's up to you if that is worth it.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, I missed the indent. Let's leave them for now, I'll experiment with it later 👍

'PLC0415', # `import` should be at the top-level of a file
]

select = [
Copy link
Member

Choose a reason for hiding this comment

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

Heh, I actually didn't know you had to select rules, since I'm used to using Ruff through hatch, which automatically selects a bunch of rules in its default settings.

@danielhollas
Copy link
Collaborator Author

I'd also squash all pre-commit related changes into one commit, if that's ok?

Sure, go for it!

Remove hooks in the `.pre-commit-config.yaml`  that can be effectively replaced by
Ruff (`pyupgrade`, `isort`, `black`). The Ruff rules `select`/`ignore` is copied from
`aiida-core`.

Co-authored-by: Daniel Hollas <daniel.hollas@bristol.ac.uk>
@mbercx mbercx force-pushed the pre-commit-update branch from c6fffd3 to 57c21d6 Compare October 1, 2025 00:08
@mbercx
Copy link
Member

mbercx commented Oct 1, 2025

Commit OCD satisfied! Have a final look, @danielhollas, and I'll approve and merge once you give a 👍

@danielhollas
Copy link
Collaborator Author

Commit OCD satisfied! Have a final look, @danielhollas, and I'll approve and merge once you give a 👍

Looks very nice, thanks!

@mbercx mbercx merged commit 8ec5948 into aiidateam:main Oct 1, 2025
6 checks passed
@danielhollas danielhollas deleted the pre-commit-update branch October 1, 2025 00:55
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