Skip to content

Commit 8273450

Browse files
committed
refactor: use super().get_id()
Signed-off-by: Tim Knight <tim.knight1@engineering.digital.dwp.gov.uk>
1 parent e7b85e0 commit 8273450

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

gitlab/v4/objects/job_token_scope.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def get_id(self) -> int:
4444
"""Returns the id of the resource. This override deals with
4545
the fact that either an `id` or a `target_project_id` attribute
4646
is returned by the server depending on the endpoint called."""
47-
try:
48-
return cast(int, getattr(self, self._id_attr))
49-
except AttributeError:
50-
return cast(int, self.id)
47+
project_id = cast(int, super().get_id())
48+
if project_id is not None:
49+
return project_id
50+
return cast(int, self.id)
5151

5252

5353
class AllowlistProjectManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
@@ -64,10 +64,10 @@ def get_id(self) -> int:
6464
"""Returns the id of the resource. This override deals with
6565
the fact that either an `id` or a `target_group_id` attribute
6666
is returned by the server depending on the endpoint called."""
67-
try:
68-
return cast(int, getattr(self, self._id_attr))
69-
except AttributeError:
70-
return cast(int, self.id)
67+
group_id = cast(int, super().get_id())
68+
if group_id is not None:
69+
return group_id
70+
return cast(int, self.id)
7171

7272

7373
class AllowlistGroupManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):

0 commit comments

Comments
 (0)