Skip to content

Add meta checks for pre-commit config#226

Open
samaloney wants to merge 2 commits intosunpy:mainfrom
samaloney:add-pre-commit-meta-checks
Open

Add meta checks for pre-commit config#226
samaloney wants to merge 2 commits intosunpy:mainfrom
samaloney:add-pre-commit-meta-checks

Conversation

@samaloney
Copy link
Member

Enable pre-commit meta checks to avoid bugs like #213

@Cadair
Copy link
Member

Cadair commented Oct 28, 2025

The CI is failing because the pre-commit is failing on the rendered template:

E       Check for useless excludes...............................................Failed
E       - hook id: check-useless-excludes
E       - exit code: 1
E       
E       The exclude pattern '.*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|packagename/extern)$' for isort does not match any files
E       The exclude pattern '.*(.fits|.fts|.fit|.header|.txt)$' for trailing-whitespace does not match any files
E       The exclude pattern '.*(.fits|.fts|.fit|.header|.txt|tca.*|.json)$|^CITATION.rst$' for end-of-file-fixer does not match any files
E       The exclude pattern '.*(.fits|.fts|.fit|.header|.txt|tca.*)$' for mixed-line-ending does not match any files
E       
E       codestyle: exit 1 (1.49 seconds) /tmp/pytest-of-runner/pytest-0/test_tox_runs_bake_examples_ur0/cookies/bake00/packagename/.tmp/codestyle> pre-commit run --color always --all-files --show-diff-on-failure pid=8141
E       codestyle: FAIL ✖ in 3.21 seconds

https://github.com/sunpy/package-template/actions/runs/18836782731/job/53739487426?pr=226#step:10:1241

@samaloney
Copy link
Member Author

Hum I can remove the the meta hook but seems to defeat the purpose or alternatively create a dummy file?

@Cadair
Copy link
Member

Cadair commented Oct 28, 2025

I'd be ok with a dummy file, but we should have it be removed here: https://github.com/sunpy/package-template/blob/main/hooks/post_gen_project.py#L53 if "include_example_code" is False.

@samaloney samaloney force-pushed the add-pre-commit-meta-checks branch from 43f6020 to 3659417 Compare February 18, 2026 16:50
@samaloney
Copy link
Member Author

So the if unless we keep some test files in the repo, even if include_example_code is False running pre-commit on a freshly minted package would fail. So I commented the check out and left a comment explaining.

I think we could probably use the files, types or types_or to set the files we want the checks to run on rather then excluding those we don't but I leave that for a different PR

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