A sample Python template project equipped with modern tooling for development.
- You need
poetry
installed to work with this repository.- Follow the installation instructions here.
- Make sure you add
poetry
to your path by adding the following line to the bottom of your~/.bashrc
or~/.bash_profile
file (choose whichever already exists):export PATH="/Users/dchiu/.local/bin:$PATH"
- Open a new Terminal window and check that
poetry
is installed by runningpoetry --version
. You should see a version number printed to the console (if you seecommand not found
,poetry
was not installed correctly).- Opening a new Terminal window reloads
bash
with new settings required to findpoetry
.
- Opening a new Terminal window reloads
- Once you have
poetry
installed, runpoetry install
in the project root to install all project dependencies. - Install
pre-commit
hooks:poetry run pre-commit install --hook-type pre-commit --hook-type pre-push
VS Code can be configured to highlight linting errors and help you reformat code to conform to style guidelines.
- Open VS Code's settings (Command + , on macOS)
- Search for
flake8
- Check the box under
Python > Linting: Flake8 Enabled
- If prompted to install
flake8
, go ahead and do so. This installsflake8
globally, and is separate frompoetry
's installedflake8
binary.
- If prompted to install
- Search again for
black
in settings - Under
Python > Formatting: Provider
, selectblack
from the dropdown menu
- To run the project:
poetry run python python_template/main.py
- To lint the project:
poetry run flake8
- To auto-format the project:
poetry run black .
- To run tests:
poetry run pytest