Skip to content

python3 setup.py lint is deprecated: Let's lint with pre-commit #2772

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
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/format-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- '**.c'
- '**.py'
- '**.rst'
- '.pre-commit-config.yaml'

pull_request:
branches: main
Expand All @@ -19,12 +20,22 @@ on:
- '**.c'
- '**.py'
- '**.rst'
- '.pre-commit-config.yaml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-format-lint
cancel-in-progress: true

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: pre-commit/[email protected]

format-lint-code-check:
runs-on: ubuntu-22.04

Expand Down
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Learn more about this config here: https://pre-commit.com/

# To enable these pre-commit hooks run:
# `brew install pre-commit` or `python3 -m pip install pre-commit`
# Then in the project root directory run `pre-commit install`

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.3.0
hooks:
- id: black
exclude: |
(?x)^(
^buildconfig/.*$
| ^docs/reST/.*$
| setup.py
)$


- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.2
hooks:
- id: clang-format
exclude: |
(?x)^(
^src_c/_sdl2/.*$
| ^src_c/doc/.*$
| docs/reST/_static/script.js
| docs/reST/_templates/header.h
| src_c/include/sse2neon.h
| src_c/pypm.c
Comment on lines +26 to +31
Copy link
Member

Choose a reason for hiding this comment

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

For future reference if/when these want to be removed, I'm leaving some rationale for keeping them excluded:
src_c/_sdl2 is autogenerated from cython, we shouldn't block merges based on the linting of autogen code
src_c/doc is the same story, it's autogenerated from docs generation
src_c/include/sse2neon.h is a header that we're vendoring in, I'm not sure we need to lint it because it's from a 3rd party
src_c/pypm.c is autogenerated from cython
docs/reST/_templates/header.h is the template for the src_c/doc generated files and isn't a valid C header file itself, so using a C linter would probably cause a black hole or something, I dunno
docs/reST/_static/script.js I dunno about this one, something something sphinx, maybe someone else can enlighten me on this file

)$