Skip to content

Commit 18552c6

Browse files
author
huangsong
committed
check the api return value is dict
1 parent a1928ab commit 18552c6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pydantic_client/container.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
class Parser:
17-
querystring_pattern = re.compile(r"\{(.*?)\}")
17+
querystring_pattern = re.compile(r"{(.*?)}")
1818

1919
@staticmethod
2020
def _apply_args(
@@ -59,7 +59,10 @@ def dict_to_body(func_args: Dict[str, Any]) -> Dict:
5959

6060
@staticmethod
6161
def get_request(method_info: MethodInfo, *args, **kwargs):
62-
func_args: Dict[str, Any] = Parser._apply_args(method_info, *args, **kwargs)
62+
# get the function the value of args
63+
func_args: Dict[str, Any] = Parser._apply_args(
64+
method_info, *args, **kwargs)
65+
# format url and render the querystring
6366
url: str = Parser._get_url(method_info, func_args)
6467

6568
body = Parser.dict_to_body(func_args)

pydantic_client/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def convert(value, target_type):
5151
rt = method_info.response_type
5252
if not rt:
5353
return value
54-
if isinstance(rt, ModelMetaclass):
54+
if isinstance(value, dict) and isinstance(rt, ModelMetaclass):
5555
return target_type(**value)
5656
try:
5757
return target_type(value)

0 commit comments

Comments
 (0)