Skip to content

Commit

Permalink
Python: Add tox commands for code format and type checking apache#3282
Browse files Browse the repository at this point in the history
  • Loading branch information
cabhishek committed Nov 1, 2021
1 parent 62b4612 commit 39ff690
Showing 1 changed file with 18 additions and 75 deletions.
93 changes: 18 additions & 75 deletions python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ usedevelop = true
deps =
coverage
mock
nose
pytest
setenv =
COVERAGE_FILE = test-reports/{envname}/.coverage
Expand All @@ -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
Expand All @@ -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=.*

Expand Down

0 comments on commit 39ff690

Please sign in to comment.