From e79d0a0571c2215c7632cb1c8dcb0e38c9e484ea Mon Sep 17 00:00:00 2001 From: dougollerenshaw Date: Fri, 4 Oct 2024 13:02:43 -0700 Subject: [PATCH] Adding flake8 to ci/cd --- .flake8 | 4 ++++ .github/workflows/flake8.yml | 27 +++++++++++++++++++++++++++ .pre-commit-config.yaml | 15 ++++++++++++++- requirements.txt | 4 +++- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 .flake8 create mode 100644 .github/workflows/flake8.yml diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..1f11ef5 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-line-length = 88 +extend-ignore = E203, E266, E501, W503 +select = B,C,E,F,W,T4,B9 diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml new file mode 100644 index 0000000..0945fcb --- /dev/null +++ b/.github/workflows/flake8.yml @@ -0,0 +1,27 @@ +name: Flake8 Linter + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 flake8-unused-arguments + - name: Run Flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 ./codeaide --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings + flake8 ./codeaide --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9120c3c..5d392f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,19 @@ repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - repo: https://github.com/psf/black rev: 23.3.0 hooks: - id: black - language_version: python3 + +- repo: https://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + additional_dependencies: [flake8-unused-arguments] diff --git a/requirements.txt b/requirements.txt index 5983f60..ef16865 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,6 @@ black isort pre-commit pyqt5 -pygments \ No newline at end of file +pygments +flake8 +flake8-unused-arguments