Skip to content

Commit c23cf2d

Browse files
Fix malformed query filter params (#389)
1 parent 78359dd commit c23cf2d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

polygon/rest/base.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,12 @@ def _get_params(
141141
elif isinstance(val, datetime):
142142
val = int(val.timestamp() * self.time_mult(datetime_res))
143143
if val is not None:
144-
if (
145-
argname.endswith("_lt")
146-
or argname.endswith("_lte")
147-
or argname.endswith("_gt")
148-
or argname.endswith("_gte")
149-
or argname.endswith("_any_of")
150-
):
151-
argname = ".".join(argname.split("_", 1))
144+
for ext in ["lt", "lte", "gt", "gte", "any_of"]:
145+
if argname.endswith(f"_{ext}"):
146+
# lop off ext, then rebuild argname with ext,
147+
# using ., and not _ (removesuffix would work)
148+
# but that is python 3.9+
149+
argname = argname[: -len(f"_{ext}")] + f".{ext}"
152150
if argname.endswith("any_of"):
153151
val = ",".join(val)
154152
params[argname] = val

0 commit comments

Comments
 (0)