-
Notifications
You must be signed in to change notification settings - Fork 61
Auto PR for https://github.com/microsoft/typespec/pull/5270 #2947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c996047
b3fb6cb
596d012
c238d55
f323374
28a6cb0
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |||||
| # Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||||||
| # -------------------------------------------------------------------------- | ||||||
| import sys | ||||||
| from typing import Any, Callable, Dict, Optional, Type, TypeVar, cast | ||||||
| from typing import Any, Callable, Dict, Optional, TypeVar | ||||||
|
|
||||||
| from azure.core.exceptions import ( | ||||||
| ClientAuthenticationError, | ||||||
|
|
@@ -68,14 +68,6 @@ async def get_pet_by_id(self, pet_id: str, **kwargs: Any) -> Optional[_models.Pe | |||||
| 401: ClientAuthenticationError, | ||||||
| 409: ResourceExistsError, | ||||||
| 304: ResourceNotModifiedError, | ||||||
| 400: HttpResponseError, | ||||||
| 404: cast( | ||||||
| Type[HttpResponseError], | ||||||
| lambda response: ResourceNotFoundError( | ||||||
| response=response, model=self._deserialize(_models.NotFoundErrorBase, response) | ||||||
| ), | ||||||
| ), | ||||||
| 501: HttpResponseError, | ||||||
| } | ||||||
| error_map.update(kwargs.pop("error_map", {}) or {}) | ||||||
|
|
||||||
|
|
@@ -99,8 +91,15 @@ async def get_pet_by_id(self, pet_id: str, **kwargs: Any) -> Optional[_models.Pe | |||||
| response = pipeline_response.http_response | ||||||
|
|
||||||
| if response.status_code not in [200, 202]: | ||||||
| map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore | ||||||
| raise HttpResponseError(response=response) | ||||||
| map_error(status_code=response.status_code, response=response, error_map=error_map) | ||||||
| error = None | ||||||
| if response.status_code == 400: | ||||||
| error = self._deserialize.failsafe_deserialize(str, pipeline_response) | ||||||
|
Member
Author
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. Why the deserialize type is |
||||||
| elif response.status_code == 404: | ||||||
| error = self._deserialize.failsafe_deserialize(_models.NotFoundErrorBase, pipeline_response) | ||||||
|
Member
Author
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.
Suggested change
I think it shall be |
||||||
| elif response.status_code == 501: | ||||||
| error = self._deserialize.failsafe_deserialize(int, pipeline_response) | ||||||
| raise HttpResponseError(response=response, model=error) | ||||||
|
Member
Author
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. For 404, old code raise |
||||||
|
|
||||||
| deserialized = None | ||||||
| if response.status_code == 200: | ||||||
|
|
@@ -126,12 +125,6 @@ async def do_something(self, what_action: str, **kwargs: Any) -> _models.PetActi | |||||
| 404: ResourceNotFoundError, | ||||||
| 409: ResourceExistsError, | ||||||
| 304: ResourceNotModifiedError, | ||||||
| 500: cast( | ||||||
| Type[HttpResponseError], | ||||||
| lambda response: HttpResponseError( | ||||||
| response=response, model=self._deserialize(_models.PetActionError, response) | ||||||
| ), | ||||||
| ), | ||||||
| } | ||||||
| error_map.update(kwargs.pop("error_map", {}) or {}) | ||||||
|
|
||||||
|
|
@@ -156,7 +149,11 @@ async def do_something(self, what_action: str, **kwargs: Any) -> _models.PetActi | |||||
|
|
||||||
| if response.status_code not in [200]: | ||||||
| map_error(status_code=response.status_code, response=response, error_map=error_map) | ||||||
| error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) | ||||||
| error = None | ||||||
| if response.status_code == 500: | ||||||
| error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) | ||||||
| else: | ||||||
| error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) | ||||||
| raise HttpResponseError(response=response, model=error) | ||||||
|
|
||||||
| deserialized = self._deserialize("PetAction", pipeline_response.http_response) | ||||||
|
|
@@ -183,12 +180,6 @@ async def has_models_param(self, models: str = "value1", **kwargs: Any) -> None: | |||||
| 404: ResourceNotFoundError, | ||||||
| 409: ResourceExistsError, | ||||||
| 304: ResourceNotModifiedError, | ||||||
| 500: cast( | ||||||
| Type[HttpResponseError], | ||||||
| lambda response: HttpResponseError( | ||||||
| response=response, model=self._deserialize(_models.PetActionError, response) | ||||||
| ), | ||||||
| ), | ||||||
| } | ||||||
| error_map.update(kwargs.pop("error_map", {}) or {}) | ||||||
|
|
||||||
|
|
@@ -213,7 +204,11 @@ async def has_models_param(self, models: str = "value1", **kwargs: Any) -> None: | |||||
|
|
||||||
| if response.status_code not in [200]: | ||||||
| map_error(status_code=response.status_code, response=response, error_map=error_map) | ||||||
| error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) | ||||||
| error = None | ||||||
| if response.status_code == 500: | ||||||
| error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) | ||||||
| else: | ||||||
| error = self._deserialize.failsafe_deserialize(_models.PetActionError, pipeline_response) | ||||||
| raise HttpResponseError(response=response, model=error) | ||||||
|
|
||||||
| if cls: | ||||||
|
|
||||||
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.
For 400/501,
failsafe_deserializewill always return None so maybe we don't need the logic.