Skip to content

Commit

Permalink
🔧 accept None values in typing definition for QueryParameterType (#195)
Browse files Browse the repository at this point in the history
close #193
  • Loading branch information
Ousret authored Dec 29, 2024
1 parent 48df3bc commit a45b9d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/niquests/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
HttpMethodType: typing.TypeAlias = str
#: List of formats accepted for URL queries parameters. (e.g. /?param1=a&param2=b)
QueryParameterType: typing.TypeAlias = typing.Union[
typing.List[typing.Tuple[str, typing.Union[str, typing.List[str]]]],
typing.Mapping[str, typing.Union[str, typing.List[str]]],
typing.List[typing.Tuple[str, typing.Union[str, typing.List[str], None]]],
typing.Mapping[str, typing.Union[str, typing.List[str], None]],
bytes,
str,
]
Expand Down
4 changes: 2 additions & 2 deletions src/niquests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def _encode_params(
elif hasattr(data, "__iter__"):
result = []
for k, vs in to_key_val_list(data):
iterable_vs: typing.Iterable[str | bytes]
iterable_vs: typing.Iterable[str | bytes | None]
if isinstance(vs, (str, bytes, int, float, bool)) or not hasattr(
vs, "__iter__"
):
Expand All @@ -812,7 +812,7 @@ def _encode_params(
else:
iterable_vs = [vs]
else:
iterable_vs = vs
iterable_vs = vs if vs is not None else []
for v in iterable_vs:
if v is not None:
result.append(
Expand Down

0 comments on commit a45b9d0

Please sign in to comment.