|
1 | 1 | import functools |
| 2 | +from typing import Any |
2 | 3 |
|
3 | 4 | from starlette._utils import is_async_callable |
4 | 5 |
|
5 | 6 |
|
6 | | -def test_async_func(): |
7 | | - async def async_func(): |
| 7 | +def test_async_func() -> None: |
| 8 | + async def async_func() -> None: |
8 | 9 | ... # pragma: no cover |
9 | 10 |
|
10 | | - def func(): |
| 11 | + def func() -> None: |
11 | 12 | ... # pragma: no cover |
12 | 13 |
|
13 | 14 | assert is_async_callable(async_func) |
14 | 15 | assert not is_async_callable(func) |
15 | 16 |
|
16 | 17 |
|
17 | | -def test_async_partial(): |
18 | | - async def async_func(a, b): |
| 18 | +def test_async_partial() -> None: |
| 19 | + async def async_func(a: Any, b: Any) -> None: |
19 | 20 | ... # pragma: no cover |
20 | 21 |
|
21 | | - def func(a, b): |
| 22 | + def func(a: Any, b: Any) -> None: |
22 | 23 | ... # pragma: no cover |
23 | 24 |
|
24 | 25 | partial = functools.partial(async_func, 1) |
25 | 26 | assert is_async_callable(partial) |
26 | 27 |
|
27 | | - partial = functools.partial(func, 1) |
| 28 | + partial = functools.partial(func, 1) # type: ignore |
28 | 29 | assert not is_async_callable(partial) |
29 | 30 |
|
30 | 31 |
|
31 | | -def test_async_method(): |
| 32 | +def test_async_method() -> None: |
32 | 33 | class Async: |
33 | | - async def method(self): |
| 34 | + async def method(self) -> None: |
34 | 35 | ... # pragma: no cover |
35 | 36 |
|
36 | 37 | class Sync: |
37 | | - def method(self): |
| 38 | + def method(self) -> None: |
38 | 39 | ... # pragma: no cover |
39 | 40 |
|
40 | 41 | assert is_async_callable(Async().method) |
41 | 42 | assert not is_async_callable(Sync().method) |
42 | 43 |
|
43 | 44 |
|
44 | | -def test_async_object_call(): |
| 45 | +def test_async_object_call() -> None: |
45 | 46 | class Async: |
46 | | - async def __call__(self): |
| 47 | + async def __call__(self) -> None: |
47 | 48 | ... # pragma: no cover |
48 | 49 |
|
49 | 50 | class Sync: |
50 | | - def __call__(self): |
| 51 | + def __call__(self) -> None: |
51 | 52 | ... # pragma: no cover |
52 | 53 |
|
53 | 54 | assert is_async_callable(Async()) |
54 | 55 | assert not is_async_callable(Sync()) |
55 | 56 |
|
56 | 57 |
|
57 | | -def test_async_partial_object_call(): |
| 58 | +def test_async_partial_object_call() -> None: |
58 | 59 | class Async: |
59 | | - async def __call__(self, a, b): |
| 60 | + async def __call__( |
| 61 | + self, |
| 62 | + a: Any, |
| 63 | + b: Any, |
| 64 | + ) -> None: |
60 | 65 | ... # pragma: no cover |
61 | 66 |
|
62 | 67 | class Sync: |
63 | | - def __call__(self, a, b): |
| 68 | + def __call__( |
| 69 | + self, |
| 70 | + a: Any, |
| 71 | + b: Any, |
| 72 | + ) -> None: |
64 | 73 | ... # pragma: no cover |
65 | 74 |
|
66 | 75 | partial = functools.partial(Async(), 1) |
67 | 76 | assert is_async_callable(partial) |
68 | 77 |
|
69 | | - partial = functools.partial(Sync(), 1) |
| 78 | + partial = functools.partial(Sync(), 1) # type: ignore |
70 | 79 | assert not is_async_callable(partial) |
71 | 80 |
|
72 | 81 |
|
73 | | -def test_async_nested_partial(): |
74 | | - async def async_func(a, b): |
| 82 | +def test_async_nested_partial() -> None: |
| 83 | + async def async_func( |
| 84 | + a: Any, |
| 85 | + b: Any, |
| 86 | + ) -> None: |
75 | 87 | ... # pragma: no cover |
76 | 88 |
|
77 | 89 | partial = functools.partial(async_func, b=2) |
|
0 commit comments