Skip to content

Use pre-commit for linting #607

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Use pre-commit for linting #607

wants to merge 1 commit into from

Conversation

AlexWaygood
Copy link
Member

This PR adds a pre-commit-config file to the repo and removes our linting GitHub Actions workflow. It shouldn't be merged unless we:

  1. Agree that we want this!
  2. Either:
    a. Enable pre-commit.ci on this repo or
    b. Replace the GitHub Actions workflow with one that uses https://github.com/pre-commit/action

My main motivation for proposing this change is that there are various linting tools that I think would be useful for this project that exist conveniently as pre-commit hooks, and which can be run easily in isolated environments via pre-commit. There are actually several other tools that I'd like to add (zizmor, a security linter, would be very relevant here, I think) but which have several complaints on the repo as-is -- if this is accepted, I'll add them in followup PRs so it's easy to identify exactly why we're making each change.

The downside of this change is that we're once again using tools written in Python to lint this repo. pre-commit doesn't currently appear to have a direct or indirect dependency on typing_extensions, but that could easily change in the future. It's fairly easy to simply run pre-commit using uv or pipx to ensure that pre-commit itself is installed into a standalone virtual environment, but this does require a little bit more explanation in our CONTRIBUTING guide.

Copy link
Member Author

Choose a reason for hiding this comment

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

all the line endings have changed in this file; there are no other changes

@JelleZijlstra
Copy link
Member

The downside of this change is that we're once again using tools written in Python to lint this repo. pre-commit doesn't currently appear to have a direct or indirect dependency on typing_extensions, but that could easily change in the future.

I think this is fine for linting steps that don't attempt to import typing-extensions. It's more important for unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants