11from __future__ import annotations
22
33from collections .abc import AsyncGenerator
4- from typing import TYPE_CHECKING
54
6- from duron .codec import DefaultCodec , FunctionType
7-
8- if TYPE_CHECKING :
9- from duron .codec import Codec
10-
11- codec : Codec = DefaultCodec ()
5+ from duron .typing import FunctionType , inspect_function
126
137
148def test_no_parameters () -> None :
159 def simple_func () -> int :
1610 return 42
1711
18- result = codec . inspect_function (simple_func )
12+ result = inspect_function (simple_func )
1913
2014 assert isinstance (result , FunctionType )
2115 assert result .parameters == []
@@ -27,7 +21,7 @@ def test_no_parameters_no_return_type() -> None:
2721 def simple_func () -> None :
2822 pass
2923
30- result = codec . inspect_function (simple_func )
24+ result = inspect_function (simple_func )
3125
3226 assert isinstance (result , FunctionType )
3327 assert result .parameters == []
@@ -39,7 +33,7 @@ def test_type_annotated_parameters() -> None:
3933 def typed_func (_x : int , _y : str , _z : float ) -> bool :
4034 return True
4135
42- result = codec . inspect_function (typed_func )
36+ result = inspect_function (typed_func )
4337
4438 assert result .parameters == ["_x" , "_y" , "_z" ]
4539 assert result .parameter_types == {"_x" : int , "_y" : str , "_z" : float }
@@ -50,7 +44,7 @@ def test_return_type_annotation() -> None:
5044 def func_with_return () -> dict [str , int ]:
5145 return {}
5246
53- result = codec . inspect_function (func_with_return )
47+ result = inspect_function (func_with_return )
5448
5549 assert result .parameters == []
5650 assert result .parameter_types == {}
@@ -61,7 +55,7 @@ def test_complex_type_annotations() -> None:
6155 def complex_func (_x : int | str , _y : list [dict [str , int ]]) -> tuple [int , ...]:
6256 return (1 , 2 , 3 )
6357
64- result = codec . inspect_function (complex_func )
58+ result = inspect_function (complex_func )
6559
6660 assert result .parameters == ["_x" , "_y" ]
6761 assert result .parameter_types == {"_x" : int | str , "_y" : list [dict [str , int ]]}
@@ -72,7 +66,7 @@ def test_async_function() -> None:
7266 async def async_func (_a : int , _b : str ) -> bool : # noqa: RUF029
7367 return True
7468
75- result = codec . inspect_function (async_func )
69+ result = inspect_function (async_func )
7670
7771 assert result .parameters == ["_a" , "_b" ]
7872 assert result .parameter_types == {"_a" : int , "_b" : str }
@@ -83,7 +77,7 @@ def test_varargs_and_kwargs() -> None:
8377 def func_with_varargs (_a : int , * _args : str , ** _kwargs : bool ) -> None :
8478 pass
8579
86- result = codec . inspect_function (func_with_varargs )
80+ result = inspect_function (func_with_varargs )
8781
8882 assert result .parameters == ["_a" ]
8983 assert result .parameter_types == {"_a" : int }
@@ -94,7 +88,7 @@ def test_positional_only_and_keyword_only() -> None:
9488 def func_with_special_args (_a : int , / , _b : str , * , _c : float ) -> bool :
9589 return True
9690
97- result = codec . inspect_function (func_with_special_args )
91+ result = inspect_function (func_with_special_args )
9892
9993 assert result .parameters == ["_a" , "_b" , "_c" ]
10094 assert result .parameter_types == {"_a" : int , "_b" : str , "_c" : float }
@@ -105,7 +99,7 @@ def test_iterator() -> None:
10599 async def generator () -> AsyncGenerator [int ]: # noqa: RUF029
106100 yield 1
107101
108- result = codec . inspect_function (generator )
102+ result = inspect_function (generator )
109103
110104 assert result .parameters == []
111105 assert result .parameter_types == {}
0 commit comments