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

Pre-commit versions should be updated #75

Open
proudfeet opened this issue Sep 7, 2023 · 0 comments · May be fixed by #76
Open

Pre-commit versions should be updated #75

proudfeet opened this issue Sep 7, 2023 · 0 comments · May be fixed by #76

Comments

@proudfeet
Copy link
Member

Description of the problem

As mentioned in MindGPT-72 several of the pre-commit hooks could do with updating as they all appear to be running on versions from around March 2023 (or July 2020 in the case of pre-commit-hooks).

Details

Repo MindGPT Latest
pre-commit-hooks 3.2.0 4.4.0
black 22.10.0 23.7.0
ruff-pre-commit 0.0.257 0.0.287
mirrors-mypy 1.1.1 1.5.1
typos 1.16.1 1.16.11

You might not want to be right at the bleeding edge for some of the packages (say ruff-pre-commit which is still fairly new) but it would be worth updating in general I think.

Potential approach 1

  1. Run the builtin autoupdate in pre-commit:
pre-commit autoupdate

This will automatically update to the most recent revision on the primary branch:

[https://github.com/pre-commit/pre-commit-hooks] updating v3.2.0 -> v4.4.0
[https://github.com/psf/black] updating 22.10.0 -> 23.7.0
[https://github.com/charliermarsh/ruff-pre-commit] updating v0.0.257 -> v0.0.287
[https://github.com/pre-commit/mirrors-mypy] updating v1.1.1 -> v1.5.1
[https://github.com/crate-ci/typos] updating v1.16.1 -> v1.16.11
  1. Run pre-commit against all files in the repo to check the up-versioning has not resulted in any failures

Spoilers: it will I am afraid.

E.g. black has changed some of their prioritisation for long-line wrapping in function names.

The good news is that most of them will be autofixed with a single run (or when I have had a quick look 90% of the issues are auto-resolved).

  1. Update the dev dependencies (manually unfortunately)

Unfortunately I don't think there is a nice way to get poetry to automatically pick up the updated pre-commit hook versions so you would have to manually uplift the dependencies in pyproject.toml

  1. Update the lock file
poetry update

Optionally you could just update the dev dependencies with:

poetry update --only dev

Potential approach 2

Not really investigated this route much but would be worth a further look.

The sync_with_poetry hook flips approach 1 and takes the rev generated by poetry in the lock file as the package rev to use. It then pushes that value into the .pre-commit-config.yaml file, ensuring they remain in sync with poetry.

Documentation

Once decided upon, it would be worth including some developer documentation on how to keep the packages up to date across poetry and pre-commit.

An aside

It is also worth noting that you do not have some of your pre-commit dependencies included in the [tool.poetry.group.dev.dependencies] block. Namely: black and ruff.

Not sure if this is intentional on your part or not? You get them as secondary dependencies through several other packages but you might want to look at including them.

@proudfeet proudfeet linked a pull request Sep 8, 2023 that will close this issue
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 a pull request may close this issue.

1 participant