update black / flake8 related settings

- add flake8-black to dev extras
- update `.flake8`
- update flake8 pre-commit hook
This commit is contained in:
mauwii 2023-02-17 06:37:17 +01:00
parent 3231499992
commit 4e0fe4ad6e
No known key found for this signature in database
GPG Key ID: D923DB04ADB3F5AB
3 changed files with 67 additions and 14 deletions

50
.flake8
View File

@ -1,5 +1,47 @@
[flake8]
max-line-length = 88
extend-select = C,E,F,W,B,B9
# B905 should be enabled when we drop support for 3.9
extend-ignore = E203, E501, B905
# line length is intentionally set to 80 here because black uses Bugbear
max-line-length = 80
extend-ignore =
# See https://github.com/PyCQA/pycodestyle/issues/373
E203,
# use Bugbear's B950 instead
E501,
# from black repo https://github.com/psf/black/blob/main/.flake8
E266, W503, B907
extend-select =
# Bugbear line length
B950
exclude =
.venv,
.git,
.tox,
dist,
doc,
*lib/python*,
*egg,
build
scripts/orig_scripts/*
ldm/models/*
ldm/modules/*
ldm/data/*
ldm/generate.py
ldm/util.py
ldm/simplet2i.py
per-file-ignores =
# B950 line too long
# W605 invalid escape sequence
# F841 assigned to but never used
# F401 imported but unused
tests/test_prompt_parser.py: B950, W605, F401
tests/test_textual_inversion.py: F841
# B023 Function definition does not bind loop variable
scripts/legacy_api.py: F401, B950, B023, F841
ldm/invoke/__init__.py: F401
# B010 Do not call setattr with a constant attribute value
ldm/invoke/server_legacy.py: B010
# =====================
# flake-quote settings:
# =====================
# Set this to match black style:
inline-quotes = double

View File

@ -22,6 +22,9 @@ repos:
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-black
- flake8-bugbear
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v2.7.1'
hooks:

View File

@ -84,7 +84,14 @@ readme={content-type="text/markdown", file="README.md"}
requires-python=">=3.9, <3.11"
[project.optional-dependencies]
"dev"=["black", "flake8", "flake8-bugbear", "isort", "pre-commit"]
"dev"=[
"black[jupyter]",
"flake8",
"flake8-black",
"flake8-bugbear",
"isort",
"pre-commit",
]
"dist"=["pip-tools", "pipdeptree", "twine"]
"docs"=[
"mkdocs-git-revision-date-localized-plugin",
@ -150,13 +157,14 @@ exclude='''
'''
include='.pyi?$'
line-length=88
source=['invokeai/backend', 'ldm/invoke']
source=["installer", "invokeai/backend", "ldm/invoke"]
target-version=['py39']
[tool.isort]
extend_ignore=["scripts"]
profile="black"
py_version=39
skip_gitignore=true
skip_glob=["scripts/orig_scripts/*"]
[tool.coverage.run]
branch=true