I built this repository to have a template for all my Python projects. It uses Poetry for managing dependencies and pre-commit to avoid commits with violations to linter rules.
- Install Poetry:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
- Install requirements with:
poetry install
.
- You can change the name of your project editing the second line of
pyproject.toml
. Example:name = "my-awesome-project"
. Don't use spaces, or you'll get a syntax error. - To add a new dependency, run
poetry add name-of-your-dependency
. Examplepoetry add pandas
. It will updatepyproject.toml
andpoetry.lock
. You must include poetry.lock on git, since it will assure that you and your team have the same version of every package of your project. - For running anything using Poetry virtualenv, use
poetry run
. Examplepoetry run my_script.py
. - If you want to adapt some linter rule to your project, edit
setup.cfg
.
In order to mantain an optimal code quality, you can use the .pre-commit-config.yaml
file to setup a git pre-commit hook. It won't let you commit if your code
violates some of the rules specified in the setup.cfg
file.
If you want to use it, run poetry run pre-commit install
.