Skip to content

Commit e6258a4

Browse 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. Closes: #1081
1 parent 8b14ff0 commit e6258a4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

gitlab/mixins.py

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy