Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d90443c

Browse filesBrowse files
kernelportJohnVillalovos
authored andcommitted
feat(api): return result from SaveMixin.save()
Return the new object data when calling `SaveMixin.save()`. Also remove check for `None` value when calling `self.manager.update()` as that method only returns a dictionary.
1 parent 8b14ff0 commit d90443c
Copy full SHA for d90443c

File tree

Expand file treeCollapse file tree

1 file changed

+7
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-4
lines changed
Open diff view settings
Collapse file

‎gitlab/mixins.py‎

Copy file name to clipboardExpand all lines: gitlab/mixins.py
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,30 +525,33 @@ def _get_updated_data(self) -> Dict[str, Any]:
525525

526526
return updated_data
527527

528-
def save(self, **kwargs: Any) -> None:
528+
def save(self, **kwargs: Any) -> Optional[Dict[str, Any]]:
529529
"""Save the changes made to the object to the server.
530530
531531
The object is updated to match what the server returns.
532532
533533
Args:
534534
**kwargs: Extra options to send to the server (e.g. sudo)
535535
536+
Returns:
537+
The new object data (*not* a RESTObject)
538+
536539
Raise:
537540
GitlabAuthenticationError: If authentication is not correct
538541
GitlabUpdateError: If the server cannot perform the request
539542
"""
540543
updated_data = self._get_updated_data()
541544
# Nothing to update. Server fails if sent an empty dict.
542545
if not updated_data:
543-
return
546+
return None
544547

545548
# call the manager
546549
obj_id = self.encoded_id
547550
if TYPE_CHECKING:
548551
assert isinstance(self.manager, UpdateMixin)
549552
server_data = self.manager.update(obj_id, updated_data, **kwargs)
550-
if server_data is not None:
551-
self._update_attrs(server_data)
553+
self._update_attrs(server_data)
554+
return server_data
552555

553556

554557
class ObjectDeleteMixin(_RestObjectBase):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.