summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-01-13 14:26:38 -0800
committerJohn L. Villalovos <john@sodarock.com>2022-01-13 14:26:38 -0800
commit4ce0a87bdb2baa5fa6859557c37ca9973b5c10b6 (patch)
tree13933dae781fac595fe19b59ee556f8c4c0c5dac
parent8b14ff0756569dd0afdc364ed95f0bb7393d5407 (diff)
downloadgitlab-jlvillal/return_save.tar.gz
chore(api): return result from `SaveMixin.save()`jlvillal/return_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.
-rw-r--r--gitlab/mixins.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/gitlab/mixins.py b/gitlab/mixins.py
index b79c29e..0d22b78 100644
--- a/gitlab/mixins.py
+++ b/gitlab/mixins.py
@@ -525,7 +525,7 @@ class SaveMixin(_RestObjectBase):
return updated_data
- def save(self, **kwargs: Any) -> None:
+ def save(self, **kwargs: Any) -> Optional[Dict[str, Any]]:
"""Save the changes made to the object to the server.
The object is updated to match what the server returns.
@@ -533,6 +533,9 @@ class SaveMixin(_RestObjectBase):
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
+ Returns:
+ The new object data (*not* a RESTObject)
+
Raise:
GitlabAuthenticationError: If authentication is not correct
GitlabUpdateError: If the server cannot perform the request
@@ -540,15 +543,15 @@ class SaveMixin(_RestObjectBase):
updated_data = self._get_updated_data()
# Nothing to update. Server fails if sent an empty dict.
if not updated_data:
- return
+ return None
# call the manager
obj_id = self.encoded_id
if TYPE_CHECKING:
assert isinstance(self.manager, UpdateMixin)
server_data = self.manager.update(obj_id, updated_data, **kwargs)
- if server_data is not None:
- self._update_attrs(server_data)
+ self._update_attrs(server_data)
+ return server_data
class ObjectDeleteMixin(_RestObjectBase):