AstuteSource / chasten

:dizzy: Chasten Uses XML and XPATH to Check a Python Program's AST for Specified Patterns!
https://pypi.org/project/chasten/
GNU General Public License v2.0
7 stars 8 forks source link

feat: Enable pre-commit #122

Closed simojo closed 9 months ago

simojo commented 10 months ago
  1. Make sure the title is descriptive of what the PR includes. Don't mention issue names/numbers; save that for the description.

  2. List the names of those who contributed to the project. @simojo

  3. Link the issue the pull request is meant to fix/resolve. Closes #29

  4. Describe the contents and goal of the pull request. This PR adds pre-commit hooks. By running poetry run task pre-commit-install, a developer can easily configure pre-commit hooks to be installed for their system. The pre-commit commands are defined in .pre-commit-config.yaml, which I will put here:

# configuring pre-commit hooks for chasten.
# this ensures users do not commit problematic code
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
    - id: check-ast
      files: '\.py$'
    - id: check-case-conflict
    - id: check-merge-conflict
    - id: forbid-submodules
    - id: trailing-whitespace

  - repo: local
    hooks:
      - id: fix-linting
        files: '\.py$'
        name: Fix Linting
        entry: poetry run task lint --fix
        language: system
  1. Will coverge be maintained/increased? This does not affect coverage.

  2. What operating systems has this been tested on? How were these tests conducted? This has been tested in NixOS 22.11.2301.cff83d5032a

  3. Include a code block and/or screenshots displaying the functionality of your feature, if applicable/possible.

Initializing pre-commits via poetry

$ poetry run task pre-commit-install

The currently activated Python version 3.10.12 is not supported by the project (^3.11).
Trying to find and use a compatible version.
Using python3.11 (3.11.4)
pre-commit installed at .git/hooks/pre-commit

New commit behavior

$ touch deleteme
$ git add deleteme
$ git commit -m 'total nonsense'

check python ast.....................................(no files to check)Skipped
check for case conflicts.................................................Passed
check for merge conflicts................................................Passed
forbid submodules....................................(no files to check)Skipped
trim trailing whitespace.................................................Passed
Fix Linting..............................................................Passed
[pre-commit 1090e48] total nonsense
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 deleteme

@laurennevill @bergasanargya @gkapfham

simojo commented 9 months ago

@laurennevill this is ready for merge if there are no other holds.