Fast and easy setup of various utilities and formatters.
Copy over the following files into your new project:
.gitignoresetup.cfgpyproject.toml- Modifytarget-version = ['py310']with your own version.pre-commit-config.yamlLICENSE(if you wish to add the MIT license)
- Initialize Git:
git init poetry add --dev pre-commit pytest pytest-cov pygount taskipypoetry run pre-commit installpoetry run pre-commit autoupdate
Now you have successfully setup the following tools:
pre-commitwith various hooksblackrefurbflake8mypyisort
All that's left is running:
poetry run pre-commit run --all-files
A few tasks are defined and can be run with: poetry run task <taskname>
pc = { cmd = "pre-commit run --all-files", help = "runs precommit on all files" }
test = { cmd = "pytest", help = "runs all tests" }
test-cov = { cmd = "pytest --cov", help = "runs all tests with coverage" }
test-cov-html = { cmd = "pytest --cov --cov-report html:coverage", help = "runs all tests with coverage and outputs a report found in ./coverage/index.html" }
loc = { cmd = "poetry run pygount ./src --format=summary --suffix=py", help = "Count LOC for the project" }
pc runs precommit on all files
test runs all tests
test-cov runs all tests with coverage
test-cov-html runs all tests with coverage and outputs a report found in ./coverage/index.html
loc Count LOC for the project