Skip to content

Commit 5acee62

Browse files
TechNiickScirlat Danut
andauthored
Added type annotations to test__utils.py (#2470)
* added type annotations to test__utils.py * ignore functools.partial sync type * ruff fix * typo * type ignore --------- Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
1 parent 48ae5cc commit 5acee62

1 file changed

Lines changed: 31 additions & 19 deletions

File tree

tests/test__utils.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,89 @@
11
import functools
2+
from typing import Any
23

34
from starlette._utils import is_async_callable
45

56

6-
def test_async_func():
7-
async def async_func():
7+
def test_async_func() -> None:
8+
async def async_func() -> None:
89
... # pragma: no cover
910

10-
def func():
11+
def func() -> None:
1112
... # pragma: no cover
1213

1314
assert is_async_callable(async_func)
1415
assert not is_async_callable(func)
1516

1617

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:
1920
... # pragma: no cover
2021

21-
def func(a, b):
22+
def func(a: Any, b: Any) -> None:
2223
... # pragma: no cover
2324

2425
partial = functools.partial(async_func, 1)
2526
assert is_async_callable(partial)
2627

27-
partial = functools.partial(func, 1)
28+
partial = functools.partial(func, 1) # type: ignore
2829
assert not is_async_callable(partial)
2930

3031

31-
def test_async_method():
32+
def test_async_method() -> None:
3233
class Async:
33-
async def method(self):
34+
async def method(self) -> None:
3435
... # pragma: no cover
3536

3637
class Sync:
37-
def method(self):
38+
def method(self) -> None:
3839
... # pragma: no cover
3940

4041
assert is_async_callable(Async().method)
4142
assert not is_async_callable(Sync().method)
4243

4344

44-
def test_async_object_call():
45+
def test_async_object_call() -> None:
4546
class Async:
46-
async def __call__(self):
47+
async def __call__(self) -> None:
4748
... # pragma: no cover
4849

4950
class Sync:
50-
def __call__(self):
51+
def __call__(self) -> None:
5152
... # pragma: no cover
5253

5354
assert is_async_callable(Async())
5455
assert not is_async_callable(Sync())
5556

5657

57-
def test_async_partial_object_call():
58+
def test_async_partial_object_call() -> None:
5859
class Async:
59-
async def __call__(self, a, b):
60+
async def __call__(
61+
self,
62+
a: Any,
63+
b: Any,
64+
) -> None:
6065
... # pragma: no cover
6166

6267
class Sync:
63-
def __call__(self, a, b):
68+
def __call__(
69+
self,
70+
a: Any,
71+
b: Any,
72+
) -> None:
6473
... # pragma: no cover
6574

6675
partial = functools.partial(Async(), 1)
6776
assert is_async_callable(partial)
6877

69-
partial = functools.partial(Sync(), 1)
78+
partial = functools.partial(Sync(), 1) # type: ignore
7079
assert not is_async_callable(partial)
7180

7281

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:
7587
... # pragma: no cover
7688

7789
partial = functools.partial(async_func, b=2)

0 commit comments

Comments
 (0)