Skip to content

Commit

Permalink
v.1.5.1: fix type for depends protocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
ALittleMoron committed May 16, 2024
1 parent 7856ae4 commit c302ec3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ dev = [

[project]
name = "sqlrepo"
version = "1.5.0"
version = "1.5.1"
description = "sqlalchemy repositories with crud operations and other utils for it."
authors = [{ name = "Dmitriy Lunev", email = "dima.lunev14@gmail.com" }]
requires-python = ">=3.11"
Expand Down
6 changes: 4 additions & 2 deletions sqlrepo/ext/fastapi/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from fastapi import Depends, Request

if TYPE_CHECKING:
from collections.abc import AsyncGenerator, Generator

from fastapi import FastAPI
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm.session import Session
Expand All @@ -11,13 +13,13 @@ class SyncSessionDependsProtocol(Protocol):
"""Sync session depends protocol for FastAPI framework."""

@staticmethod
def __call__() -> Session: ... # noqa: D102
def __call__() -> Session | Generator[Session, None, None]: ... # noqa: D102

class AsyncSessionDependsProtocol(Protocol):
"""Async session depends protocol for FastAPI framework."""

@staticmethod
async def __call__() -> AsyncSession: ... # noqa: D102
async def __call__() -> AsyncSession | AsyncGenerator[AsyncSession, None]: ... # noqa: D102


def _get_session_stub() -> None:
Expand Down

0 comments on commit c302ec3

Please sign in to comment.