◐ Shell
clean mode source ↗

fix(epics): use actual group_id for save/delete operations on nested epics by JohnVillalovos · Pull Request #3279 · python-gitlab/python-gitlab

Expand Up @@ -292,13 +292,16 @@ def update( self, id: str | int | None = None, new_data: dict[str, Any] | None = None, *, _custom_path: str | None = None, **kwargs: Any, ) -> dict[str, Any]: """Update an object on the server.
Args: id: ID of the object to update (can be None if not required) new_data: the update data for the object _custom_path: Optional custom path for special API endpoints **kwargs: Extra options to send to the server (e.g. sudo)
Returns: Expand All @@ -310,7 +313,9 @@ def update( """ new_data = new_data or {}
if id is None: if _custom_path is not None: path = _custom_path elif id is None: path = self.path else: path = f"{self.path}/{utils.EncodedId(id)}" Expand Down Expand Up @@ -357,18 +362,27 @@ def set(self, key: str, value: str, **kwargs: Any) -> base.TObjCls:
class DeleteMixin(base.RESTManager[base.TObjCls]): @exc.on_http_error(exc.GitlabDeleteError) def delete(self, id: str | int | None = None, **kwargs: Any) -> None: def delete( self, id: str | int | None = None, *, _custom_path: str | None = None, **kwargs: Any, ) -> None: """Delete an object on the server.
Args: id: ID of the object to delete _custom_path: Optional custom path for special API endpoints **kwargs: Extra options to send to the server (e.g. sudo)
Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the server cannot perform the request """ if id is None: if _custom_path is not None: path = _custom_path elif id is None: path = self.path else: path = f"{self.path}/{utils.EncodedId(id)}" Expand Down Expand Up @@ -403,6 +417,12 @@ class SaveMixin(_RestObjectBase): _updated_attrs: dict[str, Any] manager: base.RESTManager[Any]
def _get_custom_path(self) -> str | None: # NOTE(jlvillal): pylint will complain for the callers with an # 'assignment-from-none' error, if we don't do this. custom_path: str | None = None return custom_path
def _get_updated_data(self) -> dict[str, Any]: updated_data = {} for attr in self.manager._update_attrs.required: Expand Down Expand Up @@ -437,7 +457,13 @@ def save(self, **kwargs: Any) -> dict[str, Any] | None: obj_id = self.encoded_id if TYPE_CHECKING: assert isinstance(self.manager, UpdateMixin) server_data = self.manager.update(obj_id, updated_data, **kwargs) custom_path = self._get_custom_path() if custom_path is None: server_data = self.manager.update(obj_id, updated_data, **kwargs) else: server_data = self.manager.update( obj_id, updated_data, _custom_path=custom_path, **kwargs ) self._update_attrs(server_data) return server_data
Expand All @@ -452,6 +478,12 @@ class ObjectDeleteMixin(_RestObjectBase): _updated_attrs: dict[str, Any] manager: base.RESTManager[Any]
def _get_custom_path(self) -> str | None: # NOTE(jlvillal): pylint will complain for the callers with an # 'assignment-from-none' error, if we don't do this. custom_path: str | None = None return custom_path
def delete(self, **kwargs: Any) -> None: """Delete the object from the server.
Expand All @@ -465,7 +497,11 @@ def delete(self, **kwargs: Any) -> None: if TYPE_CHECKING: assert isinstance(self.manager, DeleteMixin) assert self.encoded_id is not None self.manager.delete(self.encoded_id, **kwargs) custom_path = self._get_custom_path() if custom_path is None: self.manager.delete(self.encoded_id, **kwargs) else: self.manager.delete(self.encoded_id, _custom_path=custom_path, **kwargs)

class UserAgentDetailMixin(_RestObjectBase): Expand Down