cunybpl / aiodal

async data access layer and related tools for sqlalchemy core
0 stars 0 forks source link

Missing Generics for interfaces in `controllers` module. #35

Closed bsnacks000 closed 2 months ago

bsnacks000 commented 2 months ago

@tinnaing347 We need to add Generic here ... missed this when we built it. Otherwise mypy complains about Liskov when we try to specialize ...

class IListQueryable(abc.ABC, Generic[ListViewQueryParamsModelT, Auth0UserT]):  # <-------------- Add this generic 
    @abc.abstractmethod
    def query_stmt(
        self,
        transaction: TransactionManager,
        where: context.ListContext[ListViewQueryParamsModelT, Auth0UserT],
    ) -> SaSelect: ...

Then in our app it looks like this:

class BemawebPropertyListView(
    IListQueryable[BemawebPropertyQueryParams, HiveAuth0User]
):
    def query_stmt(
        self,
        transaction: TransactionManager,
        where: ListContext[BemawebPropertyQueryParams, HiveAuth0User],
    ) -> SaSelect:
       < sqla statement builder code here >