11import inspect
22from dataclasses import dataclass
3- from typing import Any , Type
3+ from typing import Any , Type , get_type_hints
44
55import pytest
66from pydantic import BaseModel
@@ -30,6 +30,7 @@ def test_parse_params_no_signature() -> None:
3030 modify_msg = src_msg .copy (deep = True )
3131 parse_params (
3232 signature = None ,
33+ type_hints = {},
3334 message = modify_msg ,
3435 )
3536
@@ -51,7 +52,11 @@ def test_func(param: test_class) -> test_class: # type: ignore
5152 kwargs = {},
5253 )
5354
54- parse_params (inspect .signature (test_func ), msg_with_args )
55+ parse_params (
56+ inspect .signature (test_func ),
57+ get_type_hints (test_func ),
58+ msg_with_args ,
59+ )
5560
5661 assert isinstance (msg_with_args .args [0 ], test_class )
5762 assert msg_with_args .args [0 ].field == "test_val"
@@ -64,7 +69,11 @@ def test_func(param: test_class) -> test_class: # type: ignore
6469 kwargs = {"param" : {"field" : "test_val" }},
6570 )
6671
67- parse_params (inspect .signature (test_func ), msg_with_kwargs )
72+ parse_params (
73+ inspect .signature (test_func ),
74+ get_type_hints (test_func ),
75+ msg_with_kwargs ,
76+ )
6877
6978 assert isinstance (msg_with_kwargs .kwargs ["param" ], test_class )
7079 assert msg_with_kwargs .kwargs ["param" ].field == "test_val"
@@ -85,7 +94,11 @@ def test_func(param: test_class) -> test_class: # type: ignore
8594 kwargs = {},
8695 )
8796
88- parse_params (inspect .signature (test_func ), msg_with_args )
97+ parse_params (
98+ inspect .signature (test_func ),
99+ get_type_hints (test_func ),
100+ msg_with_args ,
101+ )
89102
90103 assert isinstance (msg_with_args .args [0 ], dict )
91104
@@ -97,7 +110,11 @@ def test_func(param: test_class) -> test_class: # type: ignore
97110 kwargs = {"param" : {"unknown" : "unknown" }},
98111 )
99112
100- parse_params (inspect .signature (test_func ), msg_with_kwargs )
113+ parse_params (
114+ inspect .signature (test_func ),
115+ get_type_hints (test_func ),
116+ msg_with_kwargs ,
117+ )
101118
102119 assert isinstance (msg_with_kwargs .kwargs ["param" ], dict )
103120
@@ -117,7 +134,7 @@ def test_func(param: test_class) -> test_class: # type: ignore
117134 kwargs = {},
118135 )
119136
120- parse_params (inspect .signature (test_func ), msg_with_args )
137+ parse_params (inspect .signature (test_func ), get_type_hints ( test_func ), msg_with_args )
121138
122139 assert msg_with_args .args [0 ] is None
123140
@@ -129,6 +146,10 @@ def test_func(param: test_class) -> test_class: # type: ignore
129146 kwargs = {"param" : None },
130147 )
131148
132- parse_params (inspect .signature (test_func ), msg_with_kwargs )
149+ parse_params (
150+ inspect .signature (test_func ),
151+ get_type_hints (test_func ),
152+ msg_with_kwargs ,
153+ )
133154
134155 assert msg_with_kwargs .kwargs ["param" ] is None
0 commit comments