Skip to content

Commit

Permalink
autoflake and flake8 options to setup.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeweerd committed Mar 27, 2022
1 parent 2d7ced1 commit f979172
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ jobs:
- run: pip install --upgrade pip wheel
- run: >-
pip install bandit black codespell flake8 flake8-2020 flake8-bugbear
flake8-comprehensions isort mypy pytest pyupgrade safety
flake8-comprehensions isort mypy pytest pyupgrade safety mccabe
pycodestyle pyflakes
# Skipping rules that would block the flow at this moment
- run: bandit --recursive --skip B101,B105,B110,B310,B311 .
- run: black --check . || true
# Skipping codespell because of french comments
# - run: codespell --ignore-words-list="hass"
# Ignoring rules to avoid blocking, and complexity level too high
#
- run: >-
flake8 . --count
--ignore B001,W503,E722
--max-complexity=35 --max-line-length=184 --show-source --statistics
- run: flake8 .
- run: isort --check-only --profile black . || true
- run: pip install -r requirements.txt || pip install --editable . || true
- run: mkdir --parents --verbose .mypy_cache
Expand All @@ -30,5 +28,5 @@ jobs:
true
- run: pytest . || true
#- run: pytest --doctest-modules . || true
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
#- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
- run: safety check -i 43975
19 changes: 6 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
exclude: (?x)^( \.idea/.* |.*cache/.* |.scannerwork/.* |.*properties )$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: no-commit-to-branch
args: [--branch, main]
Expand All @@ -22,12 +22,12 @@ repos:
- id: check-case-conflict
# - id: check-toml
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.23.0
rev: v1.26.3
hooks:
- id: yamllint
args: [--no-warnings, -d, '{extends: relaxed, rules: {line-length: {max: 120}}}']
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
rev: v2.31.1
hooks:
- id: pyupgrade
args:
Expand All @@ -46,7 +46,7 @@ repos:
- id: python-bandit-vulnerability-check
args: [--skip, 'B101,B105,B110,B307,B310,B311', --recursive, .]
- repo: https://github.com/fsouza/autoflake8
rev: v0.3.1
rev: v0.3.2
hooks:
- id: autoflake8
args:
Expand All @@ -57,18 +57,11 @@ repos:
rev: 4.0.1
hooks:
- id: flake8
args:
- --ignore
- W503,B001,B008,E266,E401,E402,E501,E722,F401,F841
- --max-complexity=18
- --max-line-length=88
- --show-source
- --statistics
additional_dependencies:
- pyproject-flake8==0.0.1a2
- flake8-bugbear==22.1.11
- flake8-comprehensions==3.8.0
- flake8_2020==1.6.1
- flake8-2020==1.6.1
- mccabe==0.6.1
- pycodestyle==2.8.0
- pyflakes==2.4.0
Expand All @@ -86,7 +79,7 @@ repos:
# - --skip="./.*"
# - --quiet-level=2
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
rev: v0.942
hooks:
- id: mypy
args: [--ignore-missing-imports, --install-types, --non-interactive, --check-untyped-defs,
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ lint_python:
bandit --recursive --skip $(BANDIT_EXCLUDES) .
black -l 88 .
# codespell --ignore-words-list="hass" custom_components
flake8 . --count --ignore $(FLAKE_EXCLUDES) \
--max-complexity=18 --max-line-length=88 \
--show-source --statistics
flake8 .
mypy --show-error-codes --ignore-missing-imports --install-types \
--non-interactive \
custom_components test*
Expand Down
25 changes: 25 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
[tool:pytest]
asyncio_mode=strict

[autoflake8]
in-place = True
recursive = True
expand-star-imports = True
exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build

[flake8]
exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build
# To work with Black
max-line-length = 88
max-complexity = 18
show-source = True
statistics = True
# E501: line too long
# W503: Line break occurred before a binary operator
# E203: Whitespace before ':'
# D202 No blank lines allowed after function docstring
ignore =
# B001 Do not use bare `except:`, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer `except Exception:`. If you're sure what you're doing, be explicit and write `except BaseException:`.
B001,
# W503 line break before binary operator
W503,
# E722 do not use bare 'except'
E722

0 comments on commit f979172

Please sign in to comment.