Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Add tox commands for code format and type checking #3282 #3423

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/src/iceberg/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# specific language governing permissions and limitations
# under the License.

from typing import Optional


class Type(object):
def __init__(self, type_string: str, repr_string: str, is_primitive=False):
Expand Down Expand Up @@ -71,7 +73,7 @@ def __init__(
field_id: int,
name: str,
field_type: Type,
doc: str = None,
doc: Optional[str] = None,
):
self._is_optional = is_optional
self._id = field_id
Expand Down
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 --no-implicit-optional 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