Alembic

New revision

alembic revision -m "Desc"

Upgrade to head

alembic upgrade head

Usefull commands

poetry shell
poetry add fastapi
poetry add pytest --dev
poetry install
poetry install --no-dev
poetry update
poetry run
peotry remove fastapi
poetry remove pytest --no-dev
poetry [command] -vvv

Automatically activates virtual environments created by Poetry when changing to a project directory with a valid pyproject.toml

Tips

It's better to specify version of package to install to prevent to speedup resolving dependencies

poetry add package_name==1.18

instead of

poetry add package_name

or you can use these commands

PACKAGE=mypy && poetry add $PACKAGE=`poetry add $PACKAGE --dry-run 2>/dev/null | head -n1 | awk '{print substr($3, 2)}'`

Precommit

poetry run pre-commit run --all-files

or

pre-commit run --all-files

hooks:


Config

You can use environments variable or .env file or settings.toml file to set configs

Test

Write your fixtures in conftest.py and your helper functions in utils.py

poetry run python -s -m pytest tests -o log_cli=true

You can skip using docker with --docker false

poetry run python -s -m pytest tests --docker false -o log_cli=true

Production

To set environment for production you can use export ENV_FOR_DYNACONF=production