-
-
Notifications
You must be signed in to change notification settings - Fork 65
Fixes and style #425
Fixes and style #425
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -71,14 +71,14 @@ async def execute(self) -> APIResponse[_ReturnT]: | |||||||
| if self.headers.get( | ||||||||
| "Accept" | ||||||||
| ) and "application/vnd.pgrst.plan" in self.headers.get("Accept"): | ||||||||
| if not "+json" in self.headers.get("Accept"): | ||||||||
| if "+json" not in self.headers.get("Accept"): | ||||||||
| return body | ||||||||
| return APIResponse[_ReturnT].from_http_request_response(r) | ||||||||
| else: | ||||||||
| raise APIError(r.json()) | ||||||||
| except ValidationError as e: | ||||||||
| raise APIError(r.json()) from e | ||||||||
| except JSONDecodeError as e: | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): Removal of unused exception variable 'e' is a good practice.
Suggested change
|
||||||||
| except JSONDecodeError: | ||||||||
| raise APIError(generate_default_error_message(r)) | ||||||||
|
|
||||||||
|
|
||||||||
|
|
@@ -127,7 +127,7 @@ async def execute(self) -> SingleAPIResponse[_ReturnT]: | |||||||
| raise APIError(r.json()) | ||||||||
| except ValidationError as e: | ||||||||
| raise APIError(r.json()) from e | ||||||||
| except JSONDecodeError as e: | ||||||||
| except JSONDecodeError: | ||||||||
| raise APIError(generate_default_error_message(r)) | ||||||||
|
|
||||||||
|
|
||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -71,14 +71,14 @@ def execute(self) -> APIResponse[_ReturnT]: | |||||
| if self.headers.get( | ||||||
| "Accept" | ||||||
| ) and "application/vnd.pgrst.plan" in self.headers.get("Accept"): | ||||||
| if not "+json" in self.headers.get("Accept"): | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): Consistency in using 'not in' for membership checks enhances code readability.
Suggested change
|
||||||
| if "+json" not in self.headers.get("Accept"): | ||||||
| return body | ||||||
| return APIResponse[_ReturnT].from_http_request_response(r) | ||||||
| else: | ||||||
| raise APIError(r.json()) | ||||||
| except ValidationError as e: | ||||||
| raise APIError(r.json()) from e | ||||||
| except JSONDecodeError as e: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): Good removal of the unused variable 'e' in exception handling. |
||||||
| except JSONDecodeError: | ||||||
| raise APIError(generate_default_error_message(r)) | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -127,7 +127,7 @@ def execute(self) -> SingleAPIResponse[_ReturnT]: | |||||
| raise APIError(r.json()) | ||||||
| except ValidationError as e: | ||||||
| raise APIError(r.json()) from e | ||||||
| except JSONDecodeError as e: | ||||||
| except JSONDecodeError: | ||||||
| raise APIError(generate_default_error_message(r)) | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -196,7 +196,7 @@ def from_http_request_response( | |||||||
| ) -> Self: | ||||||||
| try: | ||||||||
| data = request_response.json() | ||||||||
| except JSONDecodeError as e: | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): Efficient use of exception handling by removing unused variable 'e'.
Suggested change
|
||||||||
| except JSONDecodeError: | ||||||||
| return cls(data=[], count=0) | ||||||||
| count = cls._get_count_from_http_request_response(request_response) | ||||||||
| # the type-ignore here is as pydantic needs us to pass the type parameter | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code_refinement): Improved readability with 'not in' for membership test.