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: pre-commit + black + isort + mypy #3282

Closed
danielcweeks opened this issue Oct 12, 2021 · 3 comments
Closed

Python: pre-commit + black + isort + mypy #3282

danielcweeks opened this issue Oct 12, 2021 · 3 comments
Assignees
Labels

Comments

@danielcweeks
Copy link
Contributor

Add code infra for python project including pre-commit, black, isort, mypy to enforce standards.

@cabhishek
Copy link
Contributor

@danielcweeks I'll look into setting this up

@samredai
Copy link
Contributor

Here's a suggestion for the tox.ini changes for black and isort! There's some conflict between flake8 and isort's opinions but adding I100 and I202 to flake8's ignore should get them in sync. This will also let us run tox -e format to reformat the source files accordingly before committing and pushing (maybe that's what the pre-commit hook can run?).

[testenv:format]
description = reformat all source code
basepython = python3
deps =
    black
    isort
    flake8
skip_install = true
commands =
    isort --recursive --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
deps =
    isort
commands =
    isort --recursive --project iceberg --profile black --check-only setup.py src tests

[testenv:black]
basepython = python3
skip_install = true
deps =
    black
commands =
    black --check --diff src setup.py tests

@cabhishek
Copy link
Contributor

@samredai Thanks, I opened a PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants