8000 Use pre-commit for linting by AlexWaygood · Pull Request #607 · python/typing_extensions · GitHub
[go: up one dir, main page]

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

Merged
merged 1 commit into from
Jul 7, 2025
Merged

Use pre-commit for linting #607

merged 1 commit into from
Jul 7, 2025

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.

@AlexWaygood
Copy link
Member Author

Is this something other maintainers think would be useful? Or should I close this? :-)

Copy link
Member
@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Let's do it!

@srittau srittau merged commit 813dd35 into main Jul 7, 2025
20 checks passed
@srittau srittau deleted the pre-commit branch July 7, 2025 11:02
@AlexWaygood
Copy link
Member Author

2. Either:
a. Enable pre-commit.ci on this repo or
b. Replace the GitHub Actions workflow with one that uses pre-commit/action

(We still need to do this -- I'd vote for (a) but I don't have the necessary permissions to enable to GitHub app on this repo!)

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.

3 participants
0