From 79eaad67f2ff6ef81368e77c586b8085e3a8232b Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sun, 5 Feb 2023 22:19:32 -0600 Subject: [PATCH] feat(build): run Python lint during CI --- api/Makefile | 14 +++++++++----- api/dev-requirements.txt | 6 ++++++ api/pyproject.toml | 4 ++++ api/setup.cfg | 5 ++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/api/Makefile b/api/Makefile index 9584d6f3..f6e3dfd2 100644 --- a/api/Makefile +++ b/api/Makefile @@ -3,12 +3,16 @@ onnx_env: ## create virtual env python -v venv onnx_env -ci: pip - pip install coverage hypothesis +ci: pip pip-dev lint-check $(MAKE) test -pip: +check-venv: if [ -z $${VIRTUAL_ENV+x} ]; then echo "Are you sure you want to install dependencies outside of a virtual environment?"; sleep 30; fi + +pip: check-venv + pip install -r requirements.txt + +pip-dev: check-venv pip install -r requirements.txt test: @@ -25,12 +29,12 @@ package-upload: twine upload dist/* lint-check: - black --check --preview onnx_web + black --check --preview onnx_web/ isort --check-only --skip __init__.py --filter-files onnx_web flake8 onnx_web lint-fix: - black onnx_web + black onnx_web/ isort --skip __init__.py --filter-files onnx_web flake8 onnx_web diff --git a/api/dev-requirements.txt b/api/dev-requirements.txt index 04117cda..00503e74 100644 --- a/api/dev-requirements.txt +++ b/api/dev-requirements.txt @@ -1,8 +1,14 @@ +# lint black flake8 isort mypy +# testing +coverage +hypothesis + +# types types-Flask-Cors types-jsonschema types-Pillow diff --git a/api/pyproject.toml b/api/pyproject.toml index 4f399ec1..4f00474c 100644 --- a/api/pyproject.toml +++ b/api/pyproject.toml @@ -1,3 +1,7 @@ +[tool.black] +force-exclude = '''/(lpw_stable_diffusion_onnx|pipeline_onnx_stable_diffusion_upscale).py''' + [tool.isort] profile = "black" force_to_top = ".logging" +skip_glob = ["*/lpw_stable_diffusion_onnx.py", "*/pipeline_onnx_stable_diffusion_upscale.py"] diff --git a/api/setup.cfg b/api/setup.cfg index 053f652f..9986d4f6 100644 --- a/api/setup.cfg +++ b/api/setup.cfg @@ -4,4 +4,7 @@ description-file = README.md [flake8] ignore = E203, W503 max-line-length = 160 -per-file-ignores = __init__.py:F401 \ No newline at end of file +per-file-ignores = __init__.py:F401 +exclude = + onnx_web/diffusion/lpw_stable_diffusion_onnx.py + onnx_web/diffusion/pipeline_onnx_stable_diffusion_upscale.py \ No newline at end of file