Skip to content

Commit

Permalink
STYLE: enforce PEP8 and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzobalzani committed May 10, 2024
1 parent fd9f5ca commit e2176f8
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/lint_and_style.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: lint_and_style

on:
pull_request:
push:
branches:
- main
- master

jobs:
pre-commit:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || (github.ref == 'refs/heads/main' && github.event_name == 'push') || (github.ref == 'refs/heads/master' && github.event_name == 'push')
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.9'
- run: pip install pylint & pip install -r docker/requirements.txt
- uses: pre-commit/[email protected]
pylint:
runs-on: ubuntu-latest
needs: pre-commit
continue-on-error: true
if: false #github.event_name == 'pull_request' || (github.ref == 'refs/heads/main' && github.event_name == 'push') || (github.ref == 'refs/heads/master' && github.event_name == 'push')
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.9'
- run: pip install pylint & pip install -r docker/requirements.txt
- uses: pre-commit/[email protected]
with:
extra_args: --hook-stage manual pylint-all --all-files
65 changes: 65 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-docstring-first
- id: check-toml
- id: check-yaml
- id: mixed-line-ending
args: [--fix=lf]
- id: end-of-file-fixer
- repo: https://gitlab.com/bmares/check-json5
rev: v1.0.0
hooks:
- id: check-json5
exclude: data/.*
- repo: https://github.com/hhatto/autopep8
rev: v2.1.0
hooks:
- id: autopep8
args: [--in-place, --aggressive, --exit-code]
types: [python]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
[
"--max-line-length=120",
"--errors-only",
]
- id: pylint
alias: pylint-all
name: pylint-all
entry: pylint
language: system
types: [python]
args:
[
"--max-line-length=120",
]
stages: [manual]
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [--config=setup.cfg]
additional_dependencies:
- flake8-bugbear==22.10.27
- flake8-comprehensions==3.10.1
- torchfix==0.0.2
- repo: https://github.com/facebook/usort
rev: v1.0.7
hooks:
- id: usort
name: Sort imports with µsort
description: Safe, minimal import sorting
language: python
types_or:
- python
- pyi
entry: usort format
require_serial: true
Empty file added .pylintrc
Empty file.
27 changes: 27 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[metadata]
description-file = README.md
license_file = LICENSE

[build_sphinx]
source-dir = docs/source
build-dir = docs/build
all_files = 1

[pycodestyle]
max-line-length = 120
statistics = True
show-pep8 = True
show-source = True
ignore = W391, W605, W503

[pep8]
max-line-length=120
show-pep8 = true
statistics = true
ignore = W391, W503

[flake8]
max-line-length = 120
ignore = E203, E402, W503, W391
exclude = venv
extend-select = B901, C401, C408, C409

0 comments on commit e2176f8

Please sign in to comment.