diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2021-05-02 13:12:11 +0200 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2021-05-02 13:12:11 +0200 |
commit | 796c700cf854b547afb56bb6ea47a5600f437e47 (patch) | |
tree | f236a139a844cf055c8fe9769203b481f5380a8a /gitlab/base.py | |
parent | b563cdc1a6cd585647fc53722081dceb6f7b4466 (diff) | |
download | gitlab-fix/persist-attributes-on-save.tar.gz |
fix(base): allow persisting attributes when updating objectfix/persist-attributes-on-save
Diffstat (limited to 'gitlab/base.py')
-rw-r--r-- | gitlab/base.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gitlab/base.py b/gitlab/base.py index 7121cb0..317ae61 100644 --- a/gitlab/base.py +++ b/gitlab/base.py @@ -45,6 +45,7 @@ class RESTObject(object): _attrs: Dict[str, Any] _module: ModuleType _parent_attrs: Dict[str, Any] + _persist_attrs: bool _short_print_attr: Optional[str] = None _updated_attrs: Dict[str, Any] manager: "RESTManager" @@ -59,6 +60,7 @@ class RESTObject(object): } ) self.__dict__["_parent_attrs"] = self.manager.parent_attrs + self.__dict__["_persist_attrs"] = False self._create_managers() def __getstate__(self) -> Dict[str, Any]: @@ -153,7 +155,11 @@ class RESTObject(object): def _update_attrs(self, new_attrs: Dict[str, Any]) -> None: self.__dict__["_updated_attrs"] = {} - self.__dict__["_attrs"] = new_attrs + + if self.__dict__["_persist_attrs"] is True: + self.__dict__["_attrs"].update(new_attrs) + else: + self.__dict__["_attrs"] = new_attrs def get_id(self): """Returns the id of the resource.""" |