From 75758bf26bca286ec57d5cef2808560c395ff7ec Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Thu, 13 Jan 2022 16:26:42 -0800 Subject: [PATCH] chore(objects): use `self.encoded_id` where applicable Updated a few remaining usages of `self.id` to use `self.encoded_id` as for the most part we shouldn't be using `self.id` There are now only a few (4 lines of code) remaining uses of `self.id`, most of which seem that they should stay that way. --- gitlab/v4/objects/todos.py | 2 +- gitlab/v4/objects/users.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gitlab/v4/objects/todos.py b/gitlab/v4/objects/todos.py index e441efff3..8bfef0900 100644 --- a/gitlab/v4/objects/todos.py +++ b/gitlab/v4/objects/todos.py @@ -27,7 +27,7 @@ def mark_as_done(self, **kwargs: Any) -> Dict[str, Any]: Returns: A dict with the result """ - path = f"{self.manager.path}/{self.id}/mark_as_done" + path = f"{self.manager.path}/{self.encoded_id}/mark_as_done" server_data = self.manager.gitlab.http_post(path, **kwargs) if TYPE_CHECKING: assert isinstance(server_data, dict) diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py index 53376a910..f5b8f6cfc 100644 --- a/gitlab/v4/objects/users.py +++ b/gitlab/v4/objects/users.py @@ -179,7 +179,7 @@ def block(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: Returns: Whether the user status has been changed """ - path = f"/users/{self.id}/block" + path = f"/users/{self.encoded_id}/block" server_data = self.manager.gitlab.http_post(path, **kwargs) if server_data is True: self._attrs["state"] = "blocked" @@ -200,7 +200,7 @@ def follow(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: Returns: The new object data (*not* a RESTObject) """ - path = f"/users/{self.id}/follow" + path = f"/users/{self.encoded_id}/follow" return self.manager.gitlab.http_post(path, **kwargs) @cli.register_custom_action("User") @@ -218,7 +218,7 @@ def unfollow(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: Returns: The new object data (*not* a RESTObject) """ - path = f"/users/{self.id}/unfollow" + path = f"/users/{self.encoded_id}/unfollow" return self.manager.gitlab.http_post(path, **kwargs) @cli.register_custom_action("User") @@ -236,7 +236,7 @@ def unblock(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: Returns: Whether the user status has been changed """ - path = f"/users/{self.id}/unblock" + path = f"/users/{self.encoded_id}/unblock" server_data = self.manager.gitlab.http_post(path, **kwargs) if server_data is True: self._attrs["state"] = "active" @@ -257,7 +257,7 @@ def deactivate(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: Returns: Whether the user status has been changed """ - path = f"/users/{self.id}/deactivate" + path = f"/users/{self.encoded_id}/deactivate" server_data = self.manager.gitlab.http_post(path, **kwargs) if server_data: self._attrs["state"] = "deactivated" @@ -278,7 +278,7 @@ def activate(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: Returns: Whether the user status has been changed """ - path = f"/users/{self.id}/activate" + path = f"/users/{self.encoded_id}/activate" server_data = self.manager.gitlab.http_post(path, **kwargs) if server_data: self._attrs["state"] = "active"