Skip to content

Commit

Permalink
Merge branch 'master' into feature/search-users
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Jan 6, 2025
2 parents 3d328c8 + 116a6c0 commit fddb55a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ class UnSet:

def as_dict_exclude_unset(**params) -> dict[str, Any]:
return {k: v for k, v in params.items() if not isinstance(v, UnSet)}


def as_dict_exclude_none(**params) -> dict[str, Any]:
return {k: v for k, v in params.items() if v is not None}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from common_library.unset import UnSet, as_dict_exclude_unset
from common_library.exclude import UnSet, as_dict_exclude_none, as_dict_exclude_unset


def test_as_dict_exclude_unset():
Expand All @@ -13,3 +13,10 @@ def f(
assert f(par1="hi") == {"par1": "hi"}
assert f(par2=4) == {"par2": 4}
assert f(par1="hi", par2=4) == {"par1": "hi", "par2": 4}

# still expected behavior
assert as_dict_exclude_unset(par1=None) == {"par1": None}


def test_as_dict_exclude_none():
assert as_dict_exclude_none(par1=None) == {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import datetime
from typing import cast

from common_library.exclude import as_dict_exclude_none
from common_library.json_serialization import json_dumps
from common_library.unset import UnSet, as_dict_exclude_unset
from fastapi import FastAPI, status
from httpx import Response, Timeout
from models_library.api_schemas_dynamic_scheduler.dynamic_services import (
Expand Down Expand Up @@ -133,14 +133,11 @@ async def dynamic_service_retrieve(
@retry_on_errors()
@expect_status(status.HTTP_200_OK)
async def get_dynamic_services(
self,
*,
user_id: UserID | None | UnSet = UnSet.VALUE,
project_id: ProjectID | None | UnSet = UnSet.VALUE,
self, *, user_id: UserID | None = None, project_id: ProjectID | None = None
) -> Response:
return await self.client.get(
"/dynamic_services",
params=as_dict_exclude_unset(user_id=user_id, project_id=project_id),
params=as_dict_exclude_none(user_id=user_id, project_id=project_id),
)

@retry_on_errors()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import sqlalchemy as sa
from aiohttp import web
from common_library.unset import UnSet, as_dict_exclude_unset
from common_library.exclude import UnSet, as_dict_exclude_unset
from models_library.folders import (
FolderDB,
FolderID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from datetime import datetime

from aiohttp import web
from common_library.unset import UnSet, as_dict_exclude_unset
from common_library.exclude import UnSet, as_dict_exclude_unset
from models_library.folders import FolderID
from models_library.projects import ProjectID
from models_library.users import UserID
Expand Down

0 comments on commit fddb55a

Please sign in to comment.