Repository navigation
Restore the retryable trait in generated models #946
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
base: develop
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "type": "bugfix", | ||
| "description": "Fixed modeled errors with the `@retryable` trait not being retry-safe in generated clients." | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "type": "feature", | ||
| "description": "Added `RetryableTrait` to `smithy_core.traits`." | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ | |
| "OperationContextParamsTrait", | ||
| "RequiredTrait", | ||
| "RequiresLengthTrait", | ||
| "RetryableTrait", | ||
| "RpcV2CborTrait", | ||
| "RpcV2JsonTrait", | ||
| "SensitiveTrait", | ||
|
|
@@ -194,6 +195,21 @@ def __init__(self, value: "DocumentValue | DynamicTrait" = None): | |
| object.__setattr__(self, "fault", ErrorFault(self.document_value)) | ||
|
|
||
|
|
||
| @dataclass(init=False, frozen=True) | ||
| class RetryableTrait(Trait, id=ShapeID("smithy.api#retryable")): | ||
| """Indicates that an error may be retried by the client.""" | ||
|
|
||
| def __post_init__(self) -> None: | ||
| assert self.document_value is None or isinstance(self.document_value, Mapping) | ||
|
|
||
| @property | ||
| def throttling(self) -> bool: | ||
| """Whether the error is a throttling error.""" | ||
| if self.document_value is None: | ||
| return False | ||
| return self.document_value.get("throttling", False) # type: ignore | ||
|
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. We should avoid ignores when the type checker can be satisfied, especially a bare I prefer we do something like the following example instead: @property
def throttling(self) -> bool:
"""Whether the error is a throttling error."""
if not isinstance(self.document_value, Mapping):
return False
return self.document_value.get("throttling") is True |
||
|
|
||
|
|
||
| @dataclass(init=False, frozen=True) | ||
| class RequiredTrait(Trait, id=ShapeID("smithy.api#required")): | ||
| """Marks a member as required.""" | ||
|
|
||
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.
I think classifying this as an
enhancementmakes more sense. Afeaturemakessmithy-coreminor bump to 0.14.0. Every dependent pinssmithy-core~=0.13.0, so they would all need new releases too. That doesn't make sense here, since onlysmithy-coreusesRetryableTrait.