Skip to content

Refactor pre-commit configuration for pyanalyze and codespell …#15

Open
subhshrivastava29918 wants to merge 1 commit into
r-spacex:masterfrom
subhshrivastava29918:patch-1
Open

Refactor pre-commit configuration for pyanalyze and codespell …#15
subhshrivastava29918 wants to merge 1 commit into
r-spacex:masterfrom
subhshrivastava29918:patch-1

Conversation

@subhshrivastava29918

Copy link
Copy Markdown

… 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.

  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.

    ( This no correct way in this code)

  • 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
  1. 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.

( This no correct way in this code)

  • 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]

…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]
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.

1 participant