From cb0668e1fdfcda1bedd519aed7696b4b9f95a871 Mon Sep 17 00:00:00 2001 From: Dmitry Titenkov Date: Thu, 22 Jan 2026 15:34:17 +0300 Subject: [PATCH 1/6] actions --- .github/workflows/main.yml | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..41d3096 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,39 @@ +name: Derbit Client workflow + +on: + push: + branches: + - "**" + pull_request: + +jobs: + lint: + name: Lint & Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Upgrade pip + run: python -m pip install --upgrade pip + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Black check + run: black --check . + + - name: Isort check + run: isort --check-only . + + - name: Flake8 check + run: flake8 . + + - name: Run pytest + run: pytest -v From 4a2a9cab14588c2aa120b6e69a761d99085457fd Mon Sep 17 00:00:00 2001 From: Dmitry Titenkov Date: Thu, 22 Jan 2026 15:44:43 +0300 Subject: [PATCH 2/6] actions --- app/core/database.py | 12 ------------ app/core/session.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 app/core/session.py diff --git a/app/core/database.py b/app/core/database.py index 615d3de..fa2b68a 100644 --- a/app/core/database.py +++ b/app/core/database.py @@ -1,17 +1,5 @@ -from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine from sqlalchemy.orm import DeclarativeBase -from app.core.config import settings - -engine = create_async_engine(settings.database_url, future=True) - -async_session = async_sessionmaker(engine, expire_on_commit=False) - class Base(DeclarativeBase): pass - - -async def get_session(): - async with async_session() as session: - yield session diff --git a/app/core/session.py b/app/core/session.py new file mode 100644 index 0000000..cb7a8ee --- /dev/null +++ b/app/core/session.py @@ -0,0 +1,12 @@ +from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine + +from app.core.config import settings + +engine = create_async_engine(settings.database_url, future=True) + +async_session = async_sessionmaker(engine, expire_on_commit=False) + + +async def get_session(): + async with async_session() as session: + yield session From 8d0a7bbde54292deef17985f5a8797155123ba5c Mon Sep 17 00:00:00 2001 From: Dmitry Titenkov Date: Thu, 22 Jan 2026 15:47:16 +0300 Subject: [PATCH 3/6] actions --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 46a8557..93c1066 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ aiohappyeyeballs==2.6.1 aiohttp==3.13.3 aiosignal==1.4.0 +aiosqlite==0.22.1 alembic==1.18.1 amqp==5.3.1 annotated-doc==0.0.4 @@ -15,6 +16,7 @@ click==8.3.1 click-didyoumean==0.3.1 click-plugins==1.1.1.2 click-repl==0.3.0 +coverage==7.13.1 fastapi==0.128.0 flake8==7.3.0 frozenlist==1.8.0 @@ -43,6 +45,7 @@ pydantic_core==2.41.5 pyflakes==3.4.0 Pygments==2.19.2 pytest==9.0.2 +pytest-asyncio==1.3.0 python-dateutil==2.9.0.post0 python-dotenv==1.2.1 pytokens==0.3.0 From 059733f42adccf19f696cbd81e085429885faabd Mon Sep 17 00:00:00 2001 From: Dmitry Titenkov Date: Thu, 22 Jan 2026 16:16:39 +0300 Subject: [PATCH 4/6] actions --- tests/test_crud_price.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_crud_price.py b/tests/test_crud_price.py index ff253a4..4cbdfb6 100644 --- a/tests/test_crud_price.py +++ b/tests/test_crud_price.py @@ -25,6 +25,8 @@ async def session(): async with engine.begin() as conn: await conn.run_sync(Base.metadata.drop_all) + + await engine.dispose() @pytest.mark.asyncio From f3cd9b3fb94fa07cfe4b0505cea1030455a8e2b4 Mon Sep 17 00:00:00 2001 From: Dmitry Titenkov Date: Thu, 22 Jan 2026 16:18:36 +0300 Subject: [PATCH 5/6] actions --- app/core/database.py | 12 ++++++++++++ app/core/session.py | 12 ------------ tests/test_crud_price.py | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 app/core/session.py diff --git a/app/core/database.py b/app/core/database.py index fa2b68a..615d3de 100644 --- a/app/core/database.py +++ b/app/core/database.py @@ -1,5 +1,17 @@ +from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine from sqlalchemy.orm import DeclarativeBase +from app.core.config import settings + +engine = create_async_engine(settings.database_url, future=True) + +async_session = async_sessionmaker(engine, expire_on_commit=False) + class Base(DeclarativeBase): pass + + +async def get_session(): + async with async_session() as session: + yield session diff --git a/app/core/session.py b/app/core/session.py deleted file mode 100644 index cb7a8ee..0000000 --- a/app/core/session.py +++ /dev/null @@ -1,12 +0,0 @@ -from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine - -from app.core.config import settings - -engine = create_async_engine(settings.database_url, future=True) - -async_session = async_sessionmaker(engine, expire_on_commit=False) - - -async def get_session(): - async with async_session() as session: - yield session diff --git a/tests/test_crud_price.py b/tests/test_crud_price.py index 4cbdfb6..c4377c9 100644 --- a/tests/test_crud_price.py +++ b/tests/test_crud_price.py @@ -25,7 +25,7 @@ async def session(): async with engine.begin() as conn: await conn.run_sync(Base.metadata.drop_all) - + await engine.dispose() From f6d3bd22d1f2f3f17e532697c5f72ecf510b1234 Mon Sep 17 00:00:00 2001 From: Dmitry Titenkov Date: Thu, 22 Jan 2026 16:22:04 +0300 Subject: [PATCH 6/6] actions --- app/core/database.py | 12 ------------ app/core/session.py | 12 ++++++++++++ app/routers/prices.py | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 app/core/session.py diff --git a/app/core/database.py b/app/core/database.py index 615d3de..fa2b68a 100644 --- a/app/core/database.py +++ b/app/core/database.py @@ -1,17 +1,5 @@ -from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine from sqlalchemy.orm import DeclarativeBase -from app.core.config import settings - -engine = create_async_engine(settings.database_url, future=True) - -async_session = async_sessionmaker(engine, expire_on_commit=False) - class Base(DeclarativeBase): pass - - -async def get_session(): - async with async_session() as session: - yield session diff --git a/app/core/session.py b/app/core/session.py new file mode 100644 index 0000000..cb7a8ee --- /dev/null +++ b/app/core/session.py @@ -0,0 +1,12 @@ +from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine + +from app.core.config import settings + +engine = create_async_engine(settings.database_url, future=True) + +async_session = async_sessionmaker(engine, expire_on_commit=False) + + +async def get_session(): + async with async_session() as session: + yield session diff --git a/app/routers/prices.py b/app/routers/prices.py index 12499cc..9280fcc 100644 --- a/app/routers/prices.py +++ b/app/routers/prices.py @@ -1,7 +1,7 @@ from fastapi import APIRouter, Depends, HTTPException, Query from sqlalchemy.ext.asyncio import AsyncSession -from app.core.database import get_session +from app.core.session import get_session from app.crud.price_crud import CRUDPrice from app.schemas.prices import PriceReadSchema