python-gitlab 5.6.0__py3-none-any.whl → 6.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. gitlab/__init__.py +0 -1
  2. gitlab/_backends/protocol.py +9 -13
  3. gitlab/_backends/requests_backend.py +12 -12
  4. gitlab/_version.py +1 -1
  5. gitlab/base.py +48 -48
  6. gitlab/cli.py +15 -25
  7. gitlab/client.py +114 -140
  8. gitlab/config.py +16 -17
  9. gitlab/const.py +2 -0
  10. gitlab/exceptions.py +7 -5
  11. gitlab/mixins.py +154 -238
  12. gitlab/types.py +13 -14
  13. gitlab/utils.py +32 -43
  14. gitlab/v4/cli.py +51 -54
  15. gitlab/v4/objects/__init__.py +1 -0
  16. gitlab/v4/objects/access_requests.py +11 -3
  17. gitlab/v4/objects/appearance.py +12 -14
  18. gitlab/v4/objects/applications.py +5 -6
  19. gitlab/v4/objects/artifacts.py +10 -17
  20. gitlab/v4/objects/audit_events.py +4 -19
  21. gitlab/v4/objects/award_emojis.py +13 -57
  22. gitlab/v4/objects/badges.py +4 -19
  23. gitlab/v4/objects/boards.py +7 -27
  24. gitlab/v4/objects/branches.py +26 -14
  25. gitlab/v4/objects/broadcast_messages.py +3 -13
  26. gitlab/v4/objects/bulk_imports.py +6 -14
  27. gitlab/v4/objects/ci_lint.py +7 -13
  28. gitlab/v4/objects/cluster_agents.py +3 -13
  29. gitlab/v4/objects/clusters.py +13 -23
  30. gitlab/v4/objects/commits.py +23 -28
  31. gitlab/v4/objects/container_registry.py +13 -19
  32. gitlab/v4/objects/custom_attributes.py +16 -21
  33. gitlab/v4/objects/deploy_keys.py +22 -19
  34. gitlab/v4/objects/deploy_tokens.py +14 -32
  35. gitlab/v4/objects/deployments.py +13 -15
  36. gitlab/v4/objects/discussions.py +13 -29
  37. gitlab/v4/objects/draft_notes.py +4 -14
  38. gitlab/v4/objects/environments.py +13 -21
  39. gitlab/v4/objects/epics.py +14 -17
  40. gitlab/v4/objects/events.py +27 -79
  41. gitlab/v4/objects/export_import.py +7 -19
  42. gitlab/v4/objects/features.py +11 -12
  43. gitlab/v4/objects/files.py +23 -38
  44. gitlab/v4/objects/geo_nodes.py +7 -11
  45. gitlab/v4/objects/group_access_tokens.py +6 -13
  46. gitlab/v4/objects/groups.py +42 -37
  47. gitlab/v4/objects/hooks.py +4 -17
  48. gitlab/v4/objects/integrations.py +7 -18
  49. gitlab/v4/objects/invitations.py +12 -23
  50. gitlab/v4/objects/issues.py +21 -27
  51. gitlab/v4/objects/iterations.py +4 -8
  52. gitlab/v4/objects/job_token_scope.py +18 -14
  53. gitlab/v4/objects/jobs.py +17 -32
  54. gitlab/v4/objects/keys.py +8 -11
  55. gitlab/v4/objects/labels.py +19 -30
  56. gitlab/v4/objects/ldap.py +25 -9
  57. gitlab/v4/objects/member_roles.py +102 -0
  58. gitlab/v4/objects/members.py +11 -29
  59. gitlab/v4/objects/merge_request_approvals.py +31 -44
  60. gitlab/v4/objects/merge_requests.py +30 -40
  61. gitlab/v4/objects/merge_trains.py +3 -6
  62. gitlab/v4/objects/milestones.py +23 -29
  63. gitlab/v4/objects/namespaces.py +4 -10
  64. gitlab/v4/objects/notes.py +26 -69
  65. gitlab/v4/objects/notification_settings.py +5 -14
  66. gitlab/v4/objects/package_protection_rules.py +8 -8
  67. gitlab/v4/objects/packages.py +22 -37
  68. gitlab/v4/objects/pages.py +8 -14
  69. gitlab/v4/objects/personal_access_tokens.py +7 -10
  70. gitlab/v4/objects/pipelines.py +38 -47
  71. gitlab/v4/objects/project_access_tokens.py +6 -13
  72. gitlab/v4/objects/projects.py +63 -77
  73. gitlab/v4/objects/push_rules.py +13 -15
  74. gitlab/v4/objects/registry_protection_repository_rules.py +6 -7
  75. gitlab/v4/objects/registry_protection_rules.py +7 -11
  76. gitlab/v4/objects/releases.py +6 -20
  77. gitlab/v4/objects/repositories.py +25 -34
  78. gitlab/v4/objects/resource_groups.py +10 -15
  79. gitlab/v4/objects/reviewers.py +4 -2
  80. gitlab/v4/objects/runners.py +14 -13
  81. gitlab/v4/objects/secure_files.py +8 -21
  82. gitlab/v4/objects/service_accounts.py +7 -5
  83. gitlab/v4/objects/settings.py +13 -14
  84. gitlab/v4/objects/sidekiq.py +17 -18
  85. gitlab/v4/objects/snippets.py +78 -66
  86. gitlab/v4/objects/statistics.py +8 -23
  87. gitlab/v4/objects/status_checks.py +6 -3
  88. gitlab/v4/objects/tags.py +4 -13
  89. gitlab/v4/objects/templates.py +11 -59
  90. gitlab/v4/objects/todos.py +3 -6
  91. gitlab/v4/objects/topics.py +10 -21
  92. gitlab/v4/objects/triggers.py +3 -13
  93. gitlab/v4/objects/users.py +101 -93
  94. gitlab/v4/objects/variables.py +4 -19
  95. gitlab/v4/objects/wikis.py +4 -19
  96. {python_gitlab-5.6.0.dist-info → python_gitlab-6.1.0.dist-info}/METADATA +3 -2
  97. python_gitlab-6.1.0.dist-info/RECORD +107 -0
  98. {python_gitlab-5.6.0.dist-info → python_gitlab-6.1.0.dist-info}/WHEEL +1 -1
  99. python_gitlab-5.6.0.dist-info/RECORD +0 -106
  100. {python_gitlab-5.6.0.dist-info → python_gitlab-6.1.0.dist-info}/entry_points.txt +0 -0
  101. {python_gitlab-5.6.0.dist-info → python_gitlab-6.1.0.dist-info/licenses}/AUTHORS +0 -0
  102. {python_gitlab-5.6.0.dist-info → python_gitlab-6.1.0.dist-info/licenses}/COPYING +0 -0
  103. {python_gitlab-5.6.0.dist-info → python_gitlab-6.1.0.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,9 @@
1
- from typing import Any, cast, List, Optional, TYPE_CHECKING, Union
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, TYPE_CHECKING
2
4
 
3
5
  from gitlab import exceptions as exc
4
- from gitlab.base import RESTManager, RESTObject
6
+ from gitlab.base import RESTObject
5
7
  from gitlab.mixins import (
6
8
  CreateMixin,
7
9
  CRUDMixin,
@@ -36,7 +38,11 @@ class GroupApprovalRule(SaveMixin, RESTObject):
36
38
  _repr_attr = "name"
37
39
 
38
40
 
39
- class GroupApprovalRuleManager(RetrieveMixin, CreateMixin, UpdateMixin, RESTManager):
41
+ class GroupApprovalRuleManager(
42
+ RetrieveMixin[GroupApprovalRule],
43
+ CreateMixin[GroupApprovalRule],
44
+ UpdateMixin[GroupApprovalRule],
45
+ ):
40
46
  _path = "/groups/{group_id}/approval_rules"
41
47
  _obj_cls = GroupApprovalRule
42
48
  _from_parent_attrs = {"group_id": "id"}
@@ -45,17 +51,14 @@ class GroupApprovalRuleManager(RetrieveMixin, CreateMixin, UpdateMixin, RESTMana
45
51
  optional=("user_ids", "group_ids", "rule_type"),
46
52
  )
47
53
 
48
- def get(
49
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
50
- ) -> GroupApprovalRule:
51
- return cast(GroupApprovalRule, super().get(id=id, lazy=lazy, **kwargs))
52
-
53
54
 
54
55
  class ProjectApproval(SaveMixin, RESTObject):
55
56
  _id_attr = None
56
57
 
57
58
 
58
- class ProjectApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
59
+ class ProjectApprovalManager(
60
+ GetWithoutIdMixin[ProjectApproval], UpdateMixin[ProjectApproval]
61
+ ):
59
62
  _path = "/projects/{project_id}/approvals"
60
63
  _obj_cls = ProjectApproval
61
64
  _from_parent_attrs = {"project_id": "id"}
@@ -66,13 +69,10 @@ class ProjectApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
66
69
  "disable_overriding_approvers_per_merge_request",
67
70
  "merge_requests_author_approval",
68
71
  "merge_requests_disable_committers_approval",
69
- ),
72
+ )
70
73
  )
71
74
  _update_method = UpdateMethod.POST
72
75
 
73
- def get(self, **kwargs: Any) -> ProjectApproval:
74
- return cast(ProjectApproval, super().get(**kwargs))
75
-
76
76
 
77
77
  class ProjectApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject):
78
78
  _id_attr = "id"
@@ -80,7 +80,10 @@ class ProjectApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject):
80
80
 
81
81
 
82
82
  class ProjectApprovalRuleManager(
83
- RetrieveMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
83
+ RetrieveMixin[ProjectApprovalRule],
84
+ CreateMixin[ProjectApprovalRule],
85
+ UpdateMixin[ProjectApprovalRule],
86
+ DeleteMixin[ProjectApprovalRule],
84
87
  ):
85
88
  _path = "/projects/{project_id}/approval_rules"
86
89
  _obj_cls = ProjectApprovalRule
@@ -90,35 +93,30 @@ class ProjectApprovalRuleManager(
90
93
  optional=("user_ids", "group_ids", "protected_branch_ids", "usernames"),
91
94
  )
92
95
 
93
- def get(
94
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
95
- ) -> ProjectApprovalRule:
96
- return cast(ProjectApprovalRule, super().get(id=id, lazy=lazy, **kwargs))
97
-
98
96
 
99
97
  class ProjectMergeRequestApproval(SaveMixin, RESTObject):
100
98
  _id_attr = None
101
99
 
102
100
 
103
- class ProjectMergeRequestApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
101
+ class ProjectMergeRequestApprovalManager(
102
+ GetWithoutIdMixin[ProjectMergeRequestApproval],
103
+ UpdateMixin[ProjectMergeRequestApproval],
104
+ ):
104
105
  _path = "/projects/{project_id}/merge_requests/{mr_iid}/approvals"
105
106
  _obj_cls = ProjectMergeRequestApproval
106
107
  _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"}
107
108
  _update_attrs = RequiredOptional(required=("approvals_required",))
108
109
  _update_method = UpdateMethod.POST
109
110
 
110
- def get(self, **kwargs: Any) -> ProjectMergeRequestApproval:
111
- return cast(ProjectMergeRequestApproval, super().get(**kwargs))
112
-
113
111
  @exc.on_http_error(exc.GitlabUpdateError)
114
112
  def set_approvers(
115
113
  self,
116
114
  approvals_required: int,
117
- approver_ids: Optional[List[int]] = None,
118
- approver_group_ids: Optional[List[int]] = None,
115
+ approver_ids: list[int] | None = None,
116
+ approver_group_ids: list[int] | None = None,
119
117
  approval_rule_name: str = "name",
120
118
  *,
121
- approver_usernames: Optional[List[str]] = None,
119
+ approver_usernames: list[str] | None = None,
122
120
  **kwargs: Any,
123
121
  ) -> RESTObject:
124
122
  """Change MR-level allowed approvers and approver groups.
@@ -167,17 +165,14 @@ class ProjectMergeRequestApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject):
167
165
  _repr_attr = "name"
168
166
 
169
167
 
170
- class ProjectMergeRequestApprovalRuleManager(CRUDMixin, RESTManager):
168
+ class ProjectMergeRequestApprovalRuleManager(
169
+ CRUDMixin[ProjectMergeRequestApprovalRule]
170
+ ):
171
171
  _path = "/projects/{project_id}/merge_requests/{merge_request_iid}/approval_rules"
172
172
  _obj_cls = ProjectMergeRequestApprovalRule
173
173
  _from_parent_attrs = {"project_id": "project_id", "merge_request_iid": "iid"}
174
174
  _update_attrs = RequiredOptional(
175
- required=(
176
- "id",
177
- "merge_request_iid",
178
- "name",
179
- "approvals_required",
180
- ),
175
+ required=("id", "merge_request_iid", "name", "approvals_required"),
181
176
  optional=("user_ids", "group_ids", "usernames"),
182
177
  )
183
178
  # Important: When approval_project_rule_id is set, the name, users and
@@ -188,22 +183,14 @@ class ProjectMergeRequestApprovalRuleManager(CRUDMixin, RESTManager):
188
183
  optional=("approval_project_rule_id", "user_ids", "group_ids", "usernames"),
189
184
  )
190
185
 
191
- def get(
192
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
193
- ) -> ProjectMergeRequestApprovalRule:
194
- return cast(
195
- ProjectMergeRequestApprovalRule, super().get(id=id, lazy=lazy, **kwargs)
196
- )
197
-
198
186
 
199
187
  class ProjectMergeRequestApprovalState(RESTObject):
200
188
  pass
201
189
 
202
190
 
203
- class ProjectMergeRequestApprovalStateManager(GetWithoutIdMixin, RESTManager):
191
+ class ProjectMergeRequestApprovalStateManager(
192
+ GetWithoutIdMixin[ProjectMergeRequestApprovalState]
193
+ ):
204
194
  _path = "/projects/{project_id}/merge_requests/{mr_iid}/approval_state"
205
195
  _obj_cls = ProjectMergeRequestApprovalState
206
196
  _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"}
207
-
208
- def get(self, **kwargs: Any) -> ProjectMergeRequestApprovalState:
209
- return cast(ProjectMergeRequestApprovalState, super().get(**kwargs))
@@ -4,7 +4,9 @@ https://docs.gitlab.com/ee/api/merge_requests.html
4
4
  https://docs.gitlab.com/ee/api/merge_request_approvals.html
5
5
  """
6
6
 
7
- from typing import Any, cast, Dict, Optional, TYPE_CHECKING, Union
7
+ from __future__ import annotations
8
+
9
+ from typing import Any, TYPE_CHECKING
8
10
 
9
11
  import requests
10
12
 
@@ -12,7 +14,7 @@ import gitlab
12
14
  from gitlab import cli
13
15
  from gitlab import exceptions as exc
14
16
  from gitlab import types
15
- from gitlab.base import RESTManager, RESTObject, RESTObjectList
17
+ from gitlab.base import RESTObject, RESTObjectList
16
18
  from gitlab.mixins import (
17
19
  CRUDMixin,
18
20
  ListMixin,
@@ -64,7 +66,7 @@ class MergeRequest(RESTObject):
64
66
  pass
65
67
 
66
68
 
67
- class MergeRequestManager(ListMixin, RESTManager):
69
+ class MergeRequestManager(ListMixin[MergeRequest]):
68
70
  _path = "/merge_requests"
69
71
  _obj_cls = MergeRequest
70
72
  _list_filters = (
@@ -111,7 +113,7 @@ class GroupMergeRequest(RESTObject):
111
113
  pass
112
114
 
113
115
 
114
- class GroupMergeRequestManager(ListMixin, RESTManager):
116
+ class GroupMergeRequestManager(ListMixin[GroupMergeRequest]):
115
117
  _path = "/groups/{group_id}/merge_requests"
116
118
  _obj_cls = GroupMergeRequest
117
119
  _from_parent_attrs = {"group_id": "id"}
@@ -159,7 +161,7 @@ class ProjectMergeRequest(
159
161
  approval_state: ProjectMergeRequestApprovalStateManager
160
162
  approvals: ProjectMergeRequestApprovalManager
161
163
  awardemojis: ProjectMergeRequestAwardEmojiManager
162
- diffs: "ProjectMergeRequestDiffManager"
164
+ diffs: ProjectMergeRequestDiffManager
163
165
  discussions: ProjectMergeRequestDiscussionManager
164
166
  draft_notes: ProjectMergeRequestDraftNoteManager
165
167
  notes: ProjectMergeRequestNoteManager
@@ -172,7 +174,7 @@ class ProjectMergeRequest(
172
174
 
173
175
  @cli.register_custom_action(cls_names="ProjectMergeRequest")
174
176
  @exc.on_http_error(exc.GitlabMROnBuildSuccessError)
175
- def cancel_merge_when_pipeline_succeeds(self, **kwargs: Any) -> Dict[str, str]:
177
+ def cancel_merge_when_pipeline_succeeds(self, **kwargs: Any) -> dict[str, str]:
176
178
  """Cancel merge when the pipeline succeeds.
177
179
 
178
180
  Args:
@@ -201,11 +203,11 @@ class ProjectMergeRequest(
201
203
 
202
204
  @cli.register_custom_action(cls_names="ProjectMergeRequest")
203
205
  @exc.on_http_error(exc.GitlabListError)
204
- def related_issues(self, **kwargs: Any) -> RESTObjectList:
206
+ def related_issues(self, **kwargs: Any) -> RESTObjectList[ProjectIssue]:
205
207
  """List issues related to this merge request."
206
208
 
207
209
  Args:
208
- all: If True, return all the items, without pagination
210
+ get_all: If True, return all the items, without pagination
209
211
  per_page: Number of items to retrieve per request
210
212
  page: ID of the page to return (starts with page 1)
211
213
  **kwargs: Extra options to send to the server (e.g. sudo)
@@ -230,11 +232,11 @@ class ProjectMergeRequest(
230
232
 
231
233
  @cli.register_custom_action(cls_names="ProjectMergeRequest")
232
234
  @exc.on_http_error(exc.GitlabListError)
233
- def closes_issues(self, **kwargs: Any) -> RESTObjectList:
235
+ def closes_issues(self, **kwargs: Any) -> RESTObjectList[ProjectIssue]:
234
236
  """List issues that will close on merge."
235
237
 
236
238
  Args:
237
- all: If True, return all the items, without pagination
239
+ get_all: If True, return all the items, without pagination
238
240
  per_page: Number of items to retrieve per request
239
241
  page: ID of the page to return (starts with page 1)
240
242
  **kwargs: Extra options to send to the server (e.g. sudo)
@@ -255,11 +257,11 @@ class ProjectMergeRequest(
255
257
 
256
258
  @cli.register_custom_action(cls_names="ProjectMergeRequest")
257
259
  @exc.on_http_error(exc.GitlabListError)
258
- def commits(self, **kwargs: Any) -> RESTObjectList:
260
+ def commits(self, **kwargs: Any) -> RESTObjectList[ProjectCommit]:
259
261
  """List the merge request commits.
260
262
 
261
263
  Args:
262
- all: If True, return all the items, without pagination
264
+ get_all: If True, return all the items, without pagination
263
265
  per_page: Number of items to retrieve per request
264
266
  page: ID of the page to return (starts with page 1)
265
267
  **kwargs: Extra options to send to the server (e.g. sudo)
@@ -283,7 +285,7 @@ class ProjectMergeRequest(
283
285
  cls_names="ProjectMergeRequest", optional=("access_raw_diffs",)
284
286
  )
285
287
  @exc.on_http_error(exc.GitlabListError)
286
- def changes(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
288
+ def changes(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
287
289
  """List the merge request changes.
288
290
 
289
291
  Args:
@@ -301,7 +303,7 @@ class ProjectMergeRequest(
301
303
 
302
304
  @cli.register_custom_action(cls_names="ProjectMergeRequest", optional=("sha",))
303
305
  @exc.on_http_error(exc.GitlabMRApprovalError)
304
- def approve(self, sha: Optional[str] = None, **kwargs: Any) -> Dict[str, Any]:
306
+ def approve(self, sha: str | None = None, **kwargs: Any) -> dict[str, Any]:
305
307
  """Approve the merge request.
306
308
 
307
309
  Args:
@@ -343,7 +345,7 @@ class ProjectMergeRequest(
343
345
  https://docs.gitlab.com/ee/api/merge_request_approvals.html#unapprove-merge-request
344
346
  """
345
347
  path = f"{self.manager.path}/{self.encoded_id}/unapprove"
346
- data: Dict[str, Any] = {}
348
+ data: dict[str, Any] = {}
347
349
 
348
350
  server_data = self.manager.gitlab.http_post(path, post_data=data, **kwargs)
349
351
  if TYPE_CHECKING:
@@ -352,7 +354,7 @@ class ProjectMergeRequest(
352
354
 
353
355
  @cli.register_custom_action(cls_names="ProjectMergeRequest")
354
356
  @exc.on_http_error(exc.GitlabMRRebaseError)
355
- def rebase(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
357
+ def rebase(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
356
358
  """Attempt to rebase the source branch onto the target branch
357
359
 
358
360
  Args:
@@ -363,14 +365,12 @@ class ProjectMergeRequest(
363
365
  GitlabMRRebaseError: If rebasing failed
364
366
  """
365
367
  path = f"{self.manager.path}/{self.encoded_id}/rebase"
366
- data: Dict[str, Any] = {}
368
+ data: dict[str, Any] = {}
367
369
  return self.manager.gitlab.http_put(path, post_data=data, **kwargs)
368
370
 
369
371
  @cli.register_custom_action(cls_names="ProjectMergeRequest")
370
372
  @exc.on_http_error(exc.GitlabMRResetApprovalError)
371
- def reset_approvals(
372
- self, **kwargs: Any
373
- ) -> Union[Dict[str, Any], requests.Response]:
373
+ def reset_approvals(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
374
374
  """Clear all approvals of the merge request.
375
375
 
376
376
  Args:
@@ -381,12 +381,12 @@ class ProjectMergeRequest(
381
381
  GitlabMRResetApprovalError: If reset approval failed
382
382
  """
383
383
  path = f"{self.manager.path}/{self.encoded_id}/reset_approvals"
384
- data: Dict[str, Any] = {}
384
+ data: dict[str, Any] = {}
385
385
  return self.manager.gitlab.http_put(path, post_data=data, **kwargs)
386
386
 
387
387
  @cli.register_custom_action(cls_names="ProjectMergeRequest")
388
388
  @exc.on_http_error(exc.GitlabGetError)
389
- def merge_ref(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
389
+ def merge_ref(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
390
390
  """Attempt to merge changes between source and target branches into
391
391
  `refs/merge-requests/:iid/merge`.
392
392
 
@@ -410,11 +410,11 @@ class ProjectMergeRequest(
410
410
  @exc.on_http_error(exc.GitlabMRClosedError)
411
411
  def merge(
412
412
  self,
413
- merge_commit_message: Optional[str] = None,
414
- should_remove_source_branch: Optional[bool] = None,
415
- merge_when_pipeline_succeeds: Optional[bool] = None,
413
+ merge_commit_message: str | None = None,
414
+ should_remove_source_branch: bool | None = None,
415
+ merge_when_pipeline_succeeds: bool | None = None,
416
416
  **kwargs: Any,
417
- ) -> Dict[str, Any]:
417
+ ) -> dict[str, Any]:
418
418
  """Accept the merge request.
419
419
 
420
420
  Args:
@@ -430,7 +430,7 @@ class ProjectMergeRequest(
430
430
  GitlabMRClosedError: If the merge failed
431
431
  """
432
432
  path = f"{self.manager.path}/{self.encoded_id}/merge"
433
- data: Dict[str, Any] = {}
433
+ data: dict[str, Any] = {}
434
434
  if merge_commit_message:
435
435
  data["merge_commit_message"] = merge_commit_message
436
436
  if should_remove_source_branch is not None:
@@ -445,7 +445,7 @@ class ProjectMergeRequest(
445
445
  return server_data
446
446
 
447
447
 
448
- class ProjectMergeRequestManager(CRUDMixin, RESTManager):
448
+ class ProjectMergeRequestManager(CRUDMixin[ProjectMergeRequest]):
449
449
  _path = "/projects/{project_id}/merge_requests"
450
450
  _obj_cls = ProjectMergeRequest
451
451
  _from_parent_attrs = {"project_id": "id"}
@@ -485,7 +485,7 @@ class ProjectMergeRequestManager(CRUDMixin, RESTManager):
485
485
  "allow_maintainer_to_push",
486
486
  "squash",
487
487
  "reviewer_ids",
488
- ),
488
+ )
489
489
  )
490
490
  _list_filters = (
491
491
  "state",
@@ -517,11 +517,6 @@ class ProjectMergeRequestManager(CRUDMixin, RESTManager):
517
517
  "labels": types.CommaSeparatedListAttribute,
518
518
  }
519
519
 
520
- def get(
521
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
522
- ) -> ProjectMergeRequest:
523
- return cast(ProjectMergeRequest, super().get(id=id, lazy=lazy, **kwargs))
524
-
525
520
 
526
521
  class ProjectDeploymentMergeRequest(MergeRequest):
527
522
  pass
@@ -537,12 +532,7 @@ class ProjectMergeRequestDiff(RESTObject):
537
532
  pass
538
533
 
539
534
 
540
- class ProjectMergeRequestDiffManager(RetrieveMixin, RESTManager):
535
+ class ProjectMergeRequestDiffManager(RetrieveMixin[ProjectMergeRequestDiff]):
541
536
  _path = "/projects/{project_id}/merge_requests/{mr_iid}/versions"
542
537
  _obj_cls = ProjectMergeRequestDiff
543
538
  _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"}
544
-
545
- def get(
546
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
547
- ) -> ProjectMergeRequestDiff:
548
- return cast(ProjectMergeRequestDiff, super().get(id=id, lazy=lazy, **kwargs))
@@ -1,17 +1,14 @@
1
- from gitlab.base import RESTManager, RESTObject
1
+ from gitlab.base import RESTObject
2
2
  from gitlab.mixins import ListMixin
3
3
 
4
- __all__ = [
5
- "ProjectMergeTrain",
6
- "ProjectMergeTrainManager",
7
- ]
4
+ __all__ = ["ProjectMergeTrain", "ProjectMergeTrainManager"]
8
5
 
9
6
 
10
7
  class ProjectMergeTrain(RESTObject):
11
8
  pass
12
9
 
13
10
 
14
- class ProjectMergeTrainManager(ListMixin, RESTManager):
11
+ class ProjectMergeTrainManager(ListMixin[ProjectMergeTrain]):
15
12
  _path = "/projects/{project_id}/merge_trains"
16
13
  _obj_cls = ProjectMergeTrain
17
14
  _from_parent_attrs = {"project_id": "id"}
@@ -1,9 +1,10 @@
1
- from typing import Any, cast, TYPE_CHECKING, Union
1
+ from typing import Any, TYPE_CHECKING
2
2
 
3
3
  from gitlab import cli
4
4
  from gitlab import exceptions as exc
5
5
  from gitlab import types
6
- from gitlab.base import RESTManager, RESTObject, RESTObjectList
6
+ from gitlab.base import RESTObject, RESTObjectList
7
+ from gitlab.client import GitlabList
7
8
  from gitlab.mixins import (
8
9
  CRUDMixin,
9
10
  ObjectDeleteMixin,
@@ -16,6 +17,7 @@ from gitlab.types import RequiredOptional
16
17
  from .issues import GroupIssue, GroupIssueManager, ProjectIssue, ProjectIssueManager
17
18
  from .merge_requests import (
18
19
  GroupMergeRequest,
20
+ GroupMergeRequestManager,
19
21
  ProjectMergeRequest,
20
22
  ProjectMergeRequestManager,
21
23
  )
@@ -33,11 +35,11 @@ class GroupMilestone(SaveMixin, ObjectDeleteMixin, RESTObject):
33
35
 
34
36
  @cli.register_custom_action(cls_names="GroupMilestone")
35
37
  @exc.on_http_error(exc.GitlabListError)
36
- def issues(self, **kwargs: Any) -> RESTObjectList:
38
+ def issues(self, **kwargs: Any) -> RESTObjectList[GroupIssue]:
37
39
  """List issues related to this milestone.
38
40
 
39
41
  Args:
40
- all: If True, return all the items, without pagination
42
+ get_all: If True, return all the items, without pagination
41
43
  per_page: Number of items to retrieve per request
42
44
  page: ID of the page to return (starts with page 1)
43
45
  **kwargs: Extra options to send to the server (e.g. sudo)
@@ -53,18 +55,18 @@ class GroupMilestone(SaveMixin, ObjectDeleteMixin, RESTObject):
53
55
  path = f"{self.manager.path}/{self.encoded_id}/issues"
54
56
  data_list = self.manager.gitlab.http_list(path, iterator=True, **kwargs)
55
57
  if TYPE_CHECKING:
56
- assert isinstance(data_list, RESTObjectList)
58
+ assert isinstance(data_list, GitlabList)
57
59
  manager = GroupIssueManager(self.manager.gitlab, parent=self.manager._parent)
58
60
  # FIXME(gpocentek): the computed manager path is not correct
59
61
  return RESTObjectList(manager, GroupIssue, data_list)
60
62
 
61
63
  @cli.register_custom_action(cls_names="GroupMilestone")
62
64
  @exc.on_http_error(exc.GitlabListError)
63
- def merge_requests(self, **kwargs: Any) -> RESTObjectList:
65
+ def merge_requests(self, **kwargs: Any) -> RESTObjectList[GroupMergeRequest]:
64
66
  """List the merge requests related to this milestone.
65
67
 
66
68
  Args:
67
- all: If True, return all the items, without pagination
69
+ get_all: If True, return all the items, without pagination
68
70
  per_page: Number of items to retrieve per request
69
71
  page: ID of the page to return (starts with page 1)
70
72
  **kwargs: Extra options to send to the server (e.g. sudo)
@@ -79,13 +81,15 @@ class GroupMilestone(SaveMixin, ObjectDeleteMixin, RESTObject):
79
81
  path = f"{self.manager.path}/{self.encoded_id}/merge_requests"
80
82
  data_list = self.manager.gitlab.http_list(path, iterator=True, **kwargs)
81
83
  if TYPE_CHECKING:
82
- assert isinstance(data_list, RESTObjectList)
83
- manager = GroupIssueManager(self.manager.gitlab, parent=self.manager._parent)
84
+ assert isinstance(data_list, GitlabList)
85
+ manager = GroupMergeRequestManager(
86
+ self.manager.gitlab, parent=self.manager._parent
87
+ )
84
88
  # FIXME(gpocentek): the computed manager path is not correct
85
89
  return RESTObjectList(manager, GroupMergeRequest, data_list)
86
90
 
87
91
 
88
- class GroupMilestoneManager(CRUDMixin, RESTManager):
92
+ class GroupMilestoneManager(CRUDMixin[GroupMilestone]):
89
93
  _path = "/groups/{group_id}/milestones"
90
94
  _obj_cls = GroupMilestone
91
95
  _from_parent_attrs = {"group_id": "id"}
@@ -93,16 +97,11 @@ class GroupMilestoneManager(CRUDMixin, RESTManager):
93
97
  required=("title",), optional=("description", "due_date", "start_date")
94
98
  )
95
99
  _update_attrs = RequiredOptional(
96
- optional=("title", "description", "due_date", "start_date", "state_event"),
100
+ optional=("title", "description", "due_date", "start_date", "state_event")
97
101
  )
98
102
  _list_filters = ("iids", "state", "search")
99
103
  _types = {"iids": types.ArrayAttribute}
100
104
 
101
- def get(
102
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
103
- ) -> GroupMilestone:
104
- return cast(GroupMilestone, super().get(id=id, lazy=lazy, **kwargs))
105
-
106
105
 
107
106
  class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
108
107
  _repr_attr = "title"
@@ -110,11 +109,11 @@ class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
110
109
 
111
110
  @cli.register_custom_action(cls_names="ProjectMilestone")
112
111
  @exc.on_http_error(exc.GitlabListError)
113
- def issues(self, **kwargs: Any) -> RESTObjectList:
112
+ def issues(self, **kwargs: Any) -> RESTObjectList[ProjectIssue]:
114
113
  """List issues related to this milestone.
115
114
 
116
115
  Args:
117
- all: If True, return all the items, without pagination
116
+ get_all: If True, return all the items, without pagination
118
117
  per_page: Number of items to retrieve per request
119
118
  page: ID of the page to return (starts with page 1)
120
119
  **kwargs: Extra options to send to the server (e.g. sudo)
@@ -130,18 +129,18 @@ class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
130
129
  path = f"{self.manager.path}/{self.encoded_id}/issues"
131
130
  data_list = self.manager.gitlab.http_list(path, iterator=True, **kwargs)
132
131
  if TYPE_CHECKING:
133
- assert isinstance(data_list, RESTObjectList)
132
+ assert isinstance(data_list, GitlabList)
134
133
  manager = ProjectIssueManager(self.manager.gitlab, parent=self.manager._parent)
135
134
  # FIXME(gpocentek): the computed manager path is not correct
136
135
  return RESTObjectList(manager, ProjectIssue, data_list)
137
136
 
138
137
  @cli.register_custom_action(cls_names="ProjectMilestone")
139
138
  @exc.on_http_error(exc.GitlabListError)
140
- def merge_requests(self, **kwargs: Any) -> RESTObjectList:
139
+ def merge_requests(self, **kwargs: Any) -> RESTObjectList[ProjectMergeRequest]:
141
140
  """List the merge requests related to this milestone.
142
141
 
143
142
  Args:
144
- all: If True, return all the items, without pagination
143
+ get_all: If True, return all the items, without pagination
145
144
  per_page: Number of items to retrieve per request
146
145
  page: ID of the page to return (starts with page 1)
147
146
  **kwargs: Extra options to send to the server (e.g. sudo)
@@ -156,7 +155,7 @@ class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
156
155
  path = f"{self.manager.path}/{self.encoded_id}/merge_requests"
157
156
  data_list = self.manager.gitlab.http_list(path, iterator=True, **kwargs)
158
157
  if TYPE_CHECKING:
159
- assert isinstance(data_list, RESTObjectList)
158
+ assert isinstance(data_list, GitlabList)
160
159
  manager = ProjectMergeRequestManager(
161
160
  self.manager.gitlab, parent=self.manager._parent
162
161
  )
@@ -164,7 +163,7 @@ class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
164
163
  return RESTObjectList(manager, ProjectMergeRequest, data_list)
165
164
 
166
165
 
167
- class ProjectMilestoneManager(CRUDMixin, RESTManager):
166
+ class ProjectMilestoneManager(CRUDMixin[ProjectMilestone]):
168
167
  _path = "/projects/{project_id}/milestones"
169
168
  _obj_cls = ProjectMilestone
170
169
  _from_parent_attrs = {"project_id": "id"}
@@ -173,12 +172,7 @@ class ProjectMilestoneManager(CRUDMixin, RESTManager):
173
172
  optional=("description", "due_date", "start_date", "state_event"),
174
173
  )
175
174
  _update_attrs = RequiredOptional(
176
- optional=("title", "description", "due_date", "start_date", "state_event"),
175
+ optional=("title", "description", "due_date", "start_date", "state_event")
177
176
  )
178
177
  _list_filters = ("iids", "state", "search")
179
178
  _types = {"iids": types.ArrayAttribute}
180
-
181
- def get(
182
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
183
- ) -> ProjectMilestone:
184
- return cast(ProjectMilestone, super().get(id=id, lazy=lazy, **kwargs))
@@ -1,29 +1,23 @@
1
- from typing import Any, cast, TYPE_CHECKING, Union
1
+ from typing import Any, TYPE_CHECKING
2
2
 
3
3
  from gitlab import cli
4
4
  from gitlab import exceptions as exc
5
- from gitlab.base import RESTManager, RESTObject
5
+ from gitlab.base import RESTObject
6
6
  from gitlab.mixins import RetrieveMixin
7
7
  from gitlab.utils import EncodedId
8
8
 
9
- __all__ = [
10
- "Namespace",
11
- "NamespaceManager",
12
- ]
9
+ __all__ = ["Namespace", "NamespaceManager"]
13
10
 
14
11
 
15
12
  class Namespace(RESTObject):
16
13
  pass
17
14
 
18
15
 
19
- class NamespaceManager(RetrieveMixin, RESTManager):
16
+ class NamespaceManager(RetrieveMixin[Namespace]):
20
17
  _path = "/namespaces"
21
18
  _obj_cls = Namespace
22
19
  _list_filters = ("search",)
23
20
 
24
- def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Namespace:
25
- return cast(Namespace, super().get(id=id, lazy=lazy, **kwargs))
26
-
27
21
  @cli.register_custom_action(
28
22
  cls_names="NamespaceManager", required=("namespace", "parent_id")
29
23
  )