Skip to content

Commit

Permalink
Implement small code cleanup via a dict comprehension (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
bachya authored Nov 21, 2022
1 parent 2b8aa2d commit 534992e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions aiopurpleair/endpoints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ async def _async_endpoint_request_with_models(
Raises:
InvalidRequestError: Raised on invalid parameters.
"""
payload: dict[str, Any] = {}

for api_query_param, func_param in query_param_map:
if not func_param:
continue
payload[api_query_param] = func_param

try:
request = request_model.parse_obj(payload)
request = request_model.parse_obj(
{
api_query_param: func_param
for api_query_param, func_param in query_param_map
if func_param is not None
}
)
except ValidationError as err:
raise InvalidRequestError(err) from err

Expand Down

0 comments on commit 534992e

Please sign in to comment.