Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
task/29 make common functions file
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvanich9 committed Sep 29, 2023
1 parent f00978f commit 166c740
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Empty file added sapphire/common/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions sapphire/common/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from functools import reduce


def get_nested(storage: dict, *keys):
return reduce(
lambda value, key: value.get(key, {}) if isinstance(value, dict) else None,
keys,
storage,
)
10 changes: 1 addition & 9 deletions sapphire/users/api/v1beta/health.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import os
import pathlib
import tomllib
from functools import reduce

from sapphire.common.api.schemas import HealthResponse, ResponseStatus


def get_nested(storage: dict, *keys):
return reduce(
lambda value, key: value.get(key, {}) if isinstance(value, dict) else None,
keys,
storage,
)
from sapphire.common.functions import get_nested


async def health() -> HealthResponse:
Expand Down

0 comments on commit 166c740

Please sign in to comment.