Skip to content

acciaioli/starlette-demo

Repository files navigation

backend

Python 3.7 Build Status codecov black

Intro

This is a asgi - starlette demo project.

What's asgi? In short, the successor to wsgi!

It features:

and:

Development

Setup Poetry

Using poetry for project dependency management

# make sure poetry is installed
$ which poetry
/usr/local/bin/poetry

# how I setup poetry
$ poetry config settings.virtualenvs.create false
$ poetry config settings.virtualenvs.in-project true 

$ poetry config --list                               
settings.virtualenvs.create = false
settings.virtualenvs.in-project = true

Install Dependencies

# create venv
$ python3.7 -m venv .venv
$ source venv/bin/activate

# install project dependencies
$ poetry install

Setup Environment

# .env for development
$ ln -s .env.dev .env

Code Formatting

$ balck app tests
All done! ✨ 🍰 ✨
18 files left unchanged.

$ black app tests --check # this one is for CI

Import Sorting

$ isort -rc app tests

$ isort -rc app tests --check-only # this one is for CI

Lint Checks

$ flake8 app tests

Type Checks

$ mypy app tests

Cyclomatic Complexity

$ radon cc app -n B -s
$ radon cc tests -n B -s

$ xenon app -b A # this one is for CI
$ xenon tests -b A # this one is for CI

Run Tests

$ pytest

# for ipdb compatibale test runs
$ pytest -s

# for detailed coverage report
$ coverage html
$ firefox htmlcov/index.html

Run DB migrations

$ alembic upgrade head
...
INFO  [alembic.runtime.migration] Running upgrade  -> 8a4192a2406a, create protocols table
INFO  [alembic.runtime.migration] Running upgrade 8a4192a2406a -> 1a9952031305, update protocols table: is_cool col
...

$ alembic revision --autogenerate -m "update protocols table: add example col"
...
INFO  [alembic.autogenerate.compare] Detected added column 'protocols.example'
...

Run Dev Server

# run asgi server with auto load
$ ./dev.sh

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published