Skip to content

Conversation

spendo
Copy link

@spendo spendo commented Feb 27, 2025

related: #1219

@spendo
Copy link
Author

spendo commented Feb 27, 2025

cc @ikonst

Copy link
Contributor

@ryancausey ryancausey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikonst I just discovered this as I was looking for how to do this with PynamoDB. Is this something that can be added to the library in its current form?

return data

def save(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True) -> Dict[str, Any]:
def save(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[str] = None) -> Dict[str, Any]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be typed as:

Suggested change
def save(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[str] = None) -> Dict[str, Any]:
def save(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[Literal["ALL_OLD", "NONE"]] = None) -> Dict[str, Any]:

return schema

def _get_save_args(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True) -> Tuple[Iterable[Any], Dict[str, Any]]:
def _get_save_args(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[str] = None) -> Tuple[Iterable[Any], Dict[str, Any]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be typed as:

Suggested change
def _get_save_args(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[str] = None) -> Tuple[Iterable[Any], Dict[str, Any]]:
def _get_save_args(self, condition: Optional[Condition] = None, *, add_version_condition: bool = True, return_values_on_condition_failure: Optional[Literal["ALL_OLD", "NONE"]] = None) -> Tuple[Iterable[Any], Dict[str, Any]]:

condition &= version_condition
kwargs['attributes'] = attribute_values
kwargs['condition'] = condition
if return_values_on_condition_failure and return_values_on_condition_failure is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified to:

Suggested change
if return_values_on_condition_failure and return_values_on_condition_failure is not None:
if return_values_on_condition_failure:

return_values: Optional[str] = None,
return_consumed_capacity: Optional[str] = None,
return_item_collection_metrics: Optional[str] = None,
return_values_on_condition_failure: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be typed as:

Suggested change
return_values_on_condition_failure: Optional[str] = None,
return_values_on_condition_failure: Optional[Literal["ALL_OLD", "NONE"]] = None,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants