Skip to content

Commit fe57428

Browse files
committed
Lint fixes
1 parent c531915 commit fe57428

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

json_urley/__init__.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,24 @@ def _generate_query_params(
108108
yield key, json_obj
109109
elif isinstance(json_obj, (int, float, Decimal)):
110110
key = ".".join(current_param)
111-
if math.isnan(json_obj):
112-
value = "NaN"
113-
elif json_obj == math.inf:
114-
value = "Infinity"
115-
elif json_obj == -math.inf:
116-
value = "-Infinity"
117-
else:
118-
value = str(json_obj)
111+
value = _number_to_str(json_obj)
119112
yield key, value
120113
elif isinstance(json_obj, str):
121114
yield from _generate_query_params_for_str(json_obj, current_param)
122115
else:
123116
raise JsonUrleyError(f"unexpected_type:{json_obj}")
124117

125118

119+
def _number_to_str(value):
120+
if math.isnan(value):
121+
return "NaN"
122+
if value == math.inf:
123+
return "Infinity"
124+
if value == -math.inf:
125+
return "-Infinity"
126+
return str(value)
127+
128+
126129
def _generate_query_params_for_list(
127130
json_obj: List, current_param: List[str], is_nested_list: bool
128131
):

0 commit comments

Comments
 (0)