]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Added type annotations to test__utils.py (#2470)
authorScirlat Danut <danut.scirlat@gmail.com>
Sun, 4 Feb 2024 16:50:59 +0000 (18:50 +0200)
committerGitHub <noreply@github.com>
Sun, 4 Feb 2024 16:50:59 +0000 (16:50 +0000)
* 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>
tests/test__utils.py

index fac57a2e51b5882352662d9990f66165a4dda32b..06fece58b5a900682cd41a9fb74a84f4fc6f0656 100644 (file)
@@ -1,77 +1,89 @@
 import functools
+from typing import Any
 
 from starlette._utils import is_async_callable
 
 
-def test_async_func():
-    async def async_func():
+def test_async_func() -> None:
+    async def async_func() -> None:
         ...  # pragma: no cover
 
-    def func():
+    def func() -> None:
         ...  # pragma: no cover
 
     assert is_async_callable(async_func)
     assert not is_async_callable(func)
 
 
-def test_async_partial():
-    async def async_func(a, b):
+def test_async_partial() -> None:
+    async def async_func(a: Any, b: Any) -> None:
         ...  # pragma: no cover
 
-    def func(a, b):
+    def func(a: Any, b: Any) -> None:
         ...  # pragma: no cover
 
     partial = functools.partial(async_func, 1)
     assert is_async_callable(partial)
 
-    partial = functools.partial(func, 1)
+    partial = functools.partial(func, 1)  # type: ignore
     assert not is_async_callable(partial)
 
 
-def test_async_method():
+def test_async_method() -> None:
     class Async:
-        async def method(self):
+        async def method(self) -> None:
             ...  # pragma: no cover
 
     class Sync:
-        def method(self):
+        def method(self) -> None:
             ...  # pragma: no cover
 
     assert is_async_callable(Async().method)
     assert not is_async_callable(Sync().method)
 
 
-def test_async_object_call():
+def test_async_object_call() -> None:
     class Async:
-        async def __call__(self):
+        async def __call__(self) -> None:
             ...  # pragma: no cover
 
     class Sync:
-        def __call__(self):
+        def __call__(self) -> None:
             ...  # pragma: no cover
 
     assert is_async_callable(Async())
     assert not is_async_callable(Sync())
 
 
-def test_async_partial_object_call():
+def test_async_partial_object_call() -> None:
     class Async:
-        async def __call__(self, a, b):
+        async def __call__(
+            self,
+            a: Any,
+            b: Any,
+        ) -> None:
             ...  # pragma: no cover
 
     class Sync:
-        def __call__(self, a, b):
+        def __call__(
+            self,
+            a: Any,
+            b: Any,
+        ) -> None:
             ...  # pragma: no cover
 
     partial = functools.partial(Async(), 1)
     assert is_async_callable(partial)
 
-    partial = functools.partial(Sync(), 1)
+    partial = functools.partial(Sync(), 1)  # type: ignore
     assert not is_async_callable(partial)
 
 
-def test_async_nested_partial():
-    async def async_func(a, b):
+def test_async_nested_partial() -> None:
+    async def async_func(
+        a: Any,
+        b: Any,
+    ) -> None:
         ...  # pragma: no cover
 
     partial = functools.partial(async_func, b=2)