Refactor pre-commit configuration for pyanalyze and codespell …#15
Open
subhshrivastava29918 wants to merge 1 commit into
Open
Refactor pre-commit configuration for pyanalyze and codespell …#15subhshrivastava29918 wants to merge 1 commit into
subhshrivastava29918 wants to merge 1 commit into
Conversation
…nalyze local hook — misplaced args field) 2.( codespell hook duplicated — one stage missing)
Updated pyanalyze configuration to combine arguments into a single entry and modified codespell hook name and arguments.
1. The pyanalyze hook defines flags in both the entry field and in args. Pre-commit appends args to the command, but the main flags (--autofix --enable-all -d ... -d ...) already exist in a separate args: block. The entry command also uses -b -X dev -W error interpreter flags — these must stay in entry, but the pyanalyze-specific flags in args: could conflict or be applied twice.
- id: pyanalyze
entry: 'python -b -X dev -W error -m pyanalyze .' # ← '.' means run on all files
args: [--autofix, --enable-all, '-d', invalid_annotation,
'-d', unsupported_operation] # ← args appended again
language: system
types: [python]
pass_filenames: false
✓ Fix — move all pyanalyze flags into entry, remove args block
- id: pyanalyze
entry: 'python -b -X dev -W error -m pyanalyze --autofix --enable-all -d invalid_annotation -d unsupported_operation .'
language: system
types: [python]
pass_filenames: false
2. There are three codespell hooks across two repo blocks. The commit-msg spelling check is in a separate, second codespell repo block. While pre-commit allows a repo to appear twice when stages differ, this is fragile and confusing. The two "Check spelling" / "Fix spelling" hooks at the top also run the same binary twice with only --write-changes as the difference — if the first check fails, the second (fix) never runs, making the auto-fix unreachable in CI.
- id: codespell
name: Check spelling # stops pipeline on error ...
- id: codespell
name: Fix spelling # ... so this fix never runs in CI!
✓ Fix — use only the write-changes variant; CI will see the diff
- id: codespell
name: Check and fix spelling
exclude: '\.gitattributes'
args: ['-L', 'complet,generat', --write-changes]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… 1. (pyanalyze local hook — misplaced args field) 2.( codespell hook duplicated — one stage missing)
Updated pyanalyze configuration to combine arguments into a single entry and modified codespell hook name and arguments.
The pyanalyze hook defines flags in both the entry field and in args. Pre-commit appends args to the command, but the main flags (--autofix --enable-all -d ... -d ...) already exist in a separate args: block. The entry command also uses -b -X dev -W error interpreter flags — these must stay in entry, but the pyanalyze-specific flags in args: could conflict or be applied twice.
( This no correct way in this code)
entry: 'python -b -X dev -W error -m pyanalyze .' # ← '.' means run on all files
args: [--autofix, --enable-all, '-d', invalid_annotation,
'-d', unsupported_operation] # ← args appended again
language: system
types: [python]
pass_filenames: false
✓ Fix — move all pyanalyze flags into entry, remove args block
entry: 'python -b -X dev -W error -m pyanalyze --autofix --enable-all -d invalid_annotation -d unsupported_operation .'
language: system
types: [python]
pass_filenames: false
( This no correct way in this code)
name: Check spelling # stops pipeline on error ...
name: Fix spelling # ... so this fix never runs in CI!
✓ Fix — use only the write-changes variant; CI will see the diff
name: Check and fix spelling
exclude: '.gitattributes'
args: ['-L', 'complet,generat', --write-changes]