コード例 #1
0
ファイル: tick.py プロジェクト: dmtrs/dependable
async def tick(
    *,
    i: int,
    local_id: uuid.UUID = Depends(get_id),
    remote_id: uuid.UUID = Depends(get_remote_id),
    cpu_time: int = Depends(cpu_bound),
) -> Tuple[int, uuid.UUID, uuid.UUID, int]:
    return (i, local_id, remote_id, cpu_time)
コード例 #2
0
    def test_repr(self) -> None:
        def get_user() -> None:
            pass  # pragma: no cover

        assert repr(Depends()) == "Depends(NoneType, use_cache=False)"
        assert repr(Depends(get_user)) == "Depends(get_user, use_cache=False)"
        assert repr(Depends(use_cache=True)) == "Depends(NoneType, use_cache=True)"
        assert repr(Depends(get_user)) == "Depends(get_user, use_cache=False)"
コード例 #3
0
 async def collect(words: Iterator[str] = Depends(gen)) -> List[str]:
     actual = []
     for w in words:
         actual.append(w)
     return actual
コード例 #4
0
 def cached(r: float = Depends(_random),
            x: float = Depends(_random, use_cache=True)) -> float:
     return r is x
コード例 #5
0
 def single_cached(r: float = Depends(_random,
                                      use_cache=True)) -> float:
     return r
コード例 #6
0
 async def async_char(c: str = Depends(char)) -> str:
     raise Exception
コード例 #7
0
 async def async_char(c: C = Depends()) -> str:
     return c.value
コード例 #8
0
 async def async_char(c: str = Depends(char)) -> str:
     return c
コード例 #9
0
 async def foo(c: float = Depends(C())) -> float:
     return c
コード例 #10
0
def char(c: str = Depends(dot)) -> str:
    return c
コード例 #11
0
ファイル: basic.py プロジェクト: dmtrs/dependable
async def main_with_depends(
    *,
    _id: uuid.UUID = Depends(some_service),
    other_id: uuid.UUID = Depends(some_service),
) -> Tuple[uuid.UUID, uuid.UUID]:
    return (_id, other_id)
コード例 #12
0
async def main(*, choice: int = Depends(random)) -> None:
    print(choice)