diff --git a/.flake8 b/.flake8 deleted file mode 100644 index ee92eaf..0000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length: 120 -exclude: .git,__pycache__,docs/conf.py,build,dist,venv \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d0cda4..78aa312 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,21 +15,22 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python 3.9 + with: + fetch-depth: 0 + - name: Set up Python 3.11 uses: actions/setup-python@v5 with: - python-version: 3.9 - - name: Install tools - run: | - python -m pip install --upgrade pip - pip install -r requirements-dev.txt - - name: Lint with black - run: | - python -m black --check --diff . - - name: Lint with flake8 + python-version: 3.11 + - name: set PY + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + - uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Linting run: | - # stop the build for flake8 issues - python -m flake8 . --show-source --statistics + pip install pre-commit + pre-commit run --all-files test: needs: linting diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..23d7728 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +# .pre-commit-config.yaml +# for details see https://pre-commit.com +# for list of available hooks see https://pre-commit.com/hooks.html +# +# Preclude commits that do not conform to various criteria. + +fail_fast: true + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: # check for large files, aws credentials and private key files + - id: check-added-large-files + args: ['--maxkb=200'] + - id: detect-private-key +- repo: https://github.com/pycqa/flake8 + rev: 5.0.4 + hooks: + - id: flake8 + entry: pflake8 + additional_dependencies: [pyproject-flake8] +- repo: https://github.com/psf/black + rev: 23.1.0 + hooks: # check conformance to black formatting + - id: black + args: ['--diff', '-v'] # if run without arguments, will fail and will format the files diff --git a/pyproject.toml b/pyproject.toml index 375b1bf..3efd0e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,3 +11,7 @@ junit_family="xunit2" [tool.black] line-length = 120 exclude = '(docs/conf\.py)|venv*' + +[tool.flake8] +max-line-length = 120 +extend-exclude = "docs/conf.py,venv*"