Update pre-commit config to use poetry environment

Add precommit hook for checking for merge conflicts
Add dev dep for blacken-docs
Add dev dep for pre-commit-hooks
Update all precommit hooks to use system language
Update toxfile to use new dev deps
Fix tox vs. precommit conflicts with reorder-python-imports
This commit is contained in:
2020-11-26 12:41:06 -05:00
parent 6a5e955fce
commit 0c25ca965e
4 changed files with 324 additions and 227 deletions

33
tox.ini
View File

@@ -19,23 +19,14 @@ platform = linux
ignore_errors = true
require_locked_deps = true
locked_deps =
pre-commit
pre-commit-hooks
black
blacken-docs
reorder-python-imports
pylint
mypy
black
reorder-python-imports
pre-commit
allowlist_externals =
bash
commands =
black {toxinidir}/tox_poetry_installer/
# Oh man this is a doozy. If submodules are ever added to this plugin this will break, but I'm
# frustrated enough at this point that I'll need to take another look at it later to fix that.
# reorder-python-imports doesn't support handling directories on the CLI
# (https://github.com/asottile/reorder_python_imports/pull/76) and because the command is
# invoked directly (see comment below) we need file globbing to work around it.
# The "--unclassifiable-application-module" is a work around for reorder-python-imports not
# properly detecting the top-level module when run in a bash-wrapped command like this.
bash -c "reorder-python-imports {toxinidir}/tox_poetry_installer/*.py --unclassifiable-application-module tox_poetry_installer"
pre-commit run --all-files
pylint --rcfile {toxinidir}/.pylintrc {toxinidir}/tox_poetry_installer/
mypy --ignore-missing-imports --no-strict-optional {toxinidir}/tox_poetry_installer/
@@ -49,19 +40,9 @@ require_locked_deps = true
locked_deps =
pylint
mypy
black
reorder-python-imports
allowlist_externals =
bash
commands =
black {toxinidir}/tests/
# These bash-wrapped commands hurt my face, but these tools expect directories to be valid
# python modules, which the "tests/" directory is not. Since tox calls all commands directly
# (which is good) file globbing doesn't work. To make file globbing work they need to be wrapped
# in a bash call (which is bad).
bash -c "reorder-python-imports {toxinidir}/tests/*.py --unclassifiable-application-module tox_poetry_installer"
bash -c "pylint --rcfile {toxinidir}/.pylintrc {toxinidir}/tests/*.py"
bash -c "mypy --ignore-missing-imports --no-strict-optional {toxinidir}/tests/*.py"
pylint --rcfile {toxinidir}/.pylintrc {toxinidir}/tests/
mypy --ignore-missing-imports --no-strict-optional {toxinidir}/tests/
[testenv:security]
description = Security checks