Skip to content

Commit

Permalink
Lint with Flake8 via pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Jan 16, 2023
1 parent 496c69c commit 8a80474
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 27 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/cygwin-test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
name: test-cygwin

on:
push:
branches:
main
pull_request:
branches:
main
on: [push, pull_request, workflow_dispatch]

jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
env:
CHERE_INVOKING: 1
SHELLOPTS: igncr
Expand Down Expand Up @@ -47,11 +43,6 @@ jobs:
# If we rewrite the user's config by accident, we will mess it up
# and cause subsequent tests to fail
cat test/fixtures/.gitconfig >> ~/.gitconfig
- name: Lint with flake8
shell: bash.exe -eo pipefail -o igncr "{0}"
run: |
set -x
/usr/bin/python -m flake8
- name: Test with pytest
shell: bash.exe -eo pipefail -o igncr "{0}"
run: |
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Lint

on: [push, pull_request, workflow_dispatch]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: pre-commit/[email protected]
12 changes: 2 additions & 10 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

name: Python package

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
on: [push, pull_request, workflow_dispatch]

permissions:
contents: read
Expand All @@ -17,6 +13,7 @@ jobs:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]

Expand Down Expand Up @@ -47,11 +44,6 @@ jobs:
# and cause subsequent tests to fail
cat test/fixtures/.gitconfig >> ~/.gitconfig
- name: Lint with flake8
run: |
set -x
flake8
- name: Check types with mypy
# With new versions of pypi new issues might arise. This is a problem if there is nobody able to fix them,
# so we have to ignore errors until that changes.
Expand Down
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
[
flake8-bugbear==22.12.6,
flake8-comprehensions==3.10.1,
flake8-typing-imports==1.14.0,
]
exclude: ^doc|^git/ext/|^test/

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ with MINGW's.
Ensure testing libraries are installed.
In the root directory, run: `pip install -r test-requirements.txt`

To lint, run: `flake8`
To lint, run: `pre-commit run --all-files`

To typecheck, run: `mypy -p git`

Expand Down
5 changes: 1 addition & 4 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ mypy

black

flake8
flake8-bugbear
flake8-comprehensions
flake8-typing-imports
pre-commit

virtualenv

Expand Down

0 comments on commit 8a80474

Please sign in to comment.