Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Mar 17, 2023
1 parent 518a712 commit 95f5410
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""

from typing import Optional, Protocol
from typing import Any, Optional, Protocol

import sqlalchemy as sa

Expand All @@ -23,7 +23,7 @@ async def scalar(self, *args, **kwargs):

class _AiopgConnection(Protocol):
# Prototype to account for aiopg-only (this protocol avoids import <-> installation)
async def scalar(self, *args, **kwargs):
async def scalar(self, *args, **kwargs) -> Any:
...

async def execute(self, *args, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Any, Final, cast

from fastapi import FastAPI
from models_library.function_services_catalog.api import iter_service_docker_data
from models_library.services import ServiceDockerData
from models_library.services_db import ServiceAccessRightsAtDB, ServiceMetaDataAtDB
from packaging.version import Version
Expand All @@ -27,7 +28,6 @@
from ..db.repositories.projects import ProjectsRepository
from ..db.repositories.services import ServicesRepository
from ..services import access_rights
from ..services.function_services import iter_service_docker_data

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -83,7 +83,10 @@ async def _create_services_in_db(

services_repo = ServicesRepository(app.state.engine)

sorted_services = sorted(service_keys, key=lambda t: Version(t[1]))
def _by_version(t: tuple[ServiceKey, ServiceVersion]) -> Version:
return Version(t[1])

sorted_services = sorted(service_keys, key=_by_version)

for service_key, service_version in sorted_services:
service_metadata: ServiceDockerData = services_in_registry[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
class ProductsRepository(BaseRepository):
async def get_default_product_name(self) -> str:
async with self.db_engine.begin() as conn:
product_name = await get_default_product_name(conn)
product_name: str = await get_default_product_name(conn)
return product_name

0 comments on commit 95f5410

Please sign in to comment.