Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vrslev committed Jun 15, 2024
1 parent 8510de1 commit c30a667
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/ikea_api/error_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def handle_graphql_error(response: ResponseInfo) -> None:
if "errors" in response.json:
raise GraphQLError(response)
elif isinstance(response.json, cast(Type[List[Any]], list)):
for dict_ in cast(List[Dict[str, Any]], response.json): # pyright: ignore[reportUnknownMemberType]
for dict_ in cast(
List[Dict[str, Any]],
response.json, # pyright: ignore[reportUnknownMemberType]
):
if "errors" in dict_:
raise GraphQLError(response)
14 changes: 11 additions & 3 deletions src/ikea_api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,24 @@ class GraphQLError(APIError):

def __init__(self, response: ResponseInfo) -> None:
if isinstance(response.json, cast(Type[Dict[str, Any]], dict)):
self.errors = response.json["errors"] # pyright: ignore[reportUnknownMemberType]
self.errors = response.json[ # pyright: ignore[reportUnknownMemberType]
"errors"
]
else:
assert isinstance(response.json, cast(Type[List[Any]], list))
self.errors = []

for chunk in cast(List[Dict[str, Any]], response.json): # pyright: ignore[reportUnknownMemberType]
for chunk in cast(
List[Dict[str, Any]],
response.json, # pyright: ignore[reportUnknownMemberType]
):
if "errors" in chunk:
self.errors += chunk["errors"]

super().__init__(response, self.errors) # pyright: ignore[reportUnknownMemberType]
super().__init__(
response,
self.errors, # pyright: ignore[reportUnknownMemberType]
)


class ItemFetchError(APIError):
Expand Down

0 comments on commit c30a667

Please sign in to comment.