From 39ff6908c34d24ea350e7541090010713bedf046 Mon Sep 17 00:00:00 2001 From: Abhishek Kapatkar Date: Fri, 29 Oct 2021 14:57:14 -0700 Subject: [PATCH] Python: Add tox commands for code format and type checking #3282 --- python/tox.ini | 93 ++++++++++---------------------------------------- 1 file changed, 18 insertions(+), 75 deletions(-) diff --git a/python/tox.ini b/python/tox.ini index b099a001e362..3e46b4962845 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -23,7 +23,6 @@ usedevelop = true deps = coverage mock - nose pytest setenv = COVERAGE_FILE = test-reports/{envname}/.coverage @@ -34,79 +33,39 @@ commands = coverage report -m --fail-under=90 coverage html -d test-reports/{envname}/coverage-html coverage xml -o test-reports/{envname}/coverage.xml -[testenv:format] -description = reformat all source code -basepython = python3 -deps = - black - isort - flake8 -skip_install = true -commands = - isort --project iceberg --profile black setup.py src tests - black setup.py src tests - flake8 setup.py src tests [testenv:linters] -basepython = python3 -skip_install = true -deps = - . - {[testenv:isort]deps} - {[testenv:black]deps} - {[testenv:flake8]deps} - {[testenv:bandit]deps} - {[testenv:mypy]deps} -commands = - {[testenv:isort]deps} - {[testenv:black]deps} - {[testenv:flake8]commands} - {[testenv:bandit]commands} - {[testenv:mypy]commands} - -[testenv:isort] -basepython = python3 -skip_install = true +usedevelop = true deps = - isort + {[testenv:format-check]deps} + {[testenv:type-check]deps} commands = - isort --recursive --project iceberg --profile black --check-only setup.py src tests + {[testenv:format-check]commands} + {[testenv:type-check]commands} -[testenv:black] -basepython = python3 -skip_install = true +[testenv:format-check] deps = black + isort + autoflake commands = - black --check --diff src setup.py tests + autoflake -r --check --ignore-init-module-imports --remove-all-unused-imports setup.py src tests + isort --profile black --check-only setup.py src tests + black --check setup.py src tests -[testenv:flake8] -basepython = python3 -skip_install = true +[testenv:format] deps = - flake8>=3.8.4 - flake8-import-order>=0.9 - flake8-bugbear + {[testenv:format-check]deps} commands = - flake8 src setup.py tests + autoflake -r --in-place --ignore-init-module-imports --remove-all-unused-imports setup.py src tests + isort --profile black setup.py src tests + black setup.py src tests -[testenv:mypy] -basepython = python3 -skip_install = true +[testenv:type-check] deps = mypy - types-pytz - types-python-dateutil -commands = - mypy --ignore-missing-imports src/ - -[testenv:bandit] -basepython = python3 -skip_install = true -deps = - bandit commands = - bandit --ini tox.ini -r src + mypy src [testenv:docs] basepython = python3 @@ -124,22 +83,6 @@ deps = commands = python -m http.server {posargs} -[flake8] -ignore = E501,I100,I202,W503 -exclude = - *.egg-info, - *.pyc, - .cache, - .coverage.*, - .gradle, - .tox, - build, - dist, - htmlcov.* -max-complexity = 10 -import-order-style = google -application-import-names = flake8 - [pytest] norecursedirs=.*