Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I toggle verbose mode for all commands inside tox.ini in a simpler way?

Let us say I have a lot of commands inside my tox.ini

commands =
        poetry install -v
        poetry run pytest --typeguard-packages=news --xdoctest --cov -vv
        poetry run flake8 --verbose
        poetry run black src tests --verbose
        poetry run isort . --verbose
        poetry run bandit src --recursive --verbose
        poetry run mypy src --verbose
        poetry run darglint src --verbosity=2
        poetry run darglint tests --verbosity=2

Instead of repeating verbose everywhere, is there a way I can make all of them run with/without verbose in a simpler way?

For example, if I ran

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

poetry run tox

it runs everything without verbose, if I remove the –verbose flag from everywhere
but how do I make tox run all commands with verbose without hardcoding the verbose flag?

>Solution :

No, there is no simpler way, as you can see that the commands take different arguments to run in verbose mode.

If all commands would take the same arguments, e.g. --verbose, you could do something like…

commands =
        poetry install {posargs}
        poetry run pytest --typeguard-packages=news --xdoctest --cov {posargs}
        poetry run flake8 {posargs}
        poetry run black src tests {posargs}
        ...

and then run

tox -e lint -- --verbose

That said… "there is no way" is a lie.

You could create a bash script and run that as a tox command instead of your current list.

P.S.: I am one of the tox maintainers, but not a bash guy 🙂 So good luck with that.

P.P.S.: Out of scope of this question, but you could have a look at https://pre-commit.com/ – this is the way most Python projects I know run linters nowadays.

P.P.P.S.: You could copy/paste your env, one time with and one time without the verbose mode.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading