python-gitlab 5.5.0__py3-none-any.whl → 6.0.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 (102) 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 +14 -24
  7. gitlab/client.py +114 -140
  8. gitlab/config.py +16 -17
  9. gitlab/exceptions.py +7 -5
  10. gitlab/mixins.py +154 -238
  11. gitlab/types.py +13 -14
  12. gitlab/utils.py +32 -43
  13. gitlab/v4/cli.py +50 -53
  14. gitlab/v4/objects/__init__.py +1 -0
  15. gitlab/v4/objects/access_requests.py +11 -3
  16. gitlab/v4/objects/appearance.py +12 -14
  17. gitlab/v4/objects/applications.py +5 -6
  18. gitlab/v4/objects/artifacts.py +10 -17
  19. gitlab/v4/objects/audit_events.py +4 -19
  20. gitlab/v4/objects/award_emojis.py +13 -57
  21. gitlab/v4/objects/badges.py +4 -19
  22. gitlab/v4/objects/boards.py +7 -27
  23. gitlab/v4/objects/branches.py +3 -15
  24. gitlab/v4/objects/broadcast_messages.py +3 -13
  25. gitlab/v4/objects/bulk_imports.py +6 -14
  26. gitlab/v4/objects/ci_lint.py +7 -13
  27. gitlab/v4/objects/cluster_agents.py +3 -13
  28. gitlab/v4/objects/clusters.py +13 -23
  29. gitlab/v4/objects/commits.py +23 -28
  30. gitlab/v4/objects/container_registry.py +13 -19
  31. gitlab/v4/objects/custom_attributes.py +16 -21
  32. gitlab/v4/objects/deploy_keys.py +22 -19
  33. gitlab/v4/objects/deploy_tokens.py +14 -32
  34. gitlab/v4/objects/deployments.py +13 -15
  35. gitlab/v4/objects/discussions.py +13 -29
  36. gitlab/v4/objects/draft_notes.py +4 -14
  37. gitlab/v4/objects/environments.py +13 -21
  38. gitlab/v4/objects/epics.py +14 -17
  39. gitlab/v4/objects/events.py +27 -79
  40. gitlab/v4/objects/export_import.py +7 -19
  41. gitlab/v4/objects/features.py +11 -12
  42. gitlab/v4/objects/files.py +23 -38
  43. gitlab/v4/objects/geo_nodes.py +7 -11
  44. gitlab/v4/objects/group_access_tokens.py +6 -13
  45. gitlab/v4/objects/groups.py +42 -37
  46. gitlab/v4/objects/hooks.py +4 -17
  47. gitlab/v4/objects/integrations.py +7 -18
  48. gitlab/v4/objects/invitations.py +12 -23
  49. gitlab/v4/objects/issues.py +21 -27
  50. gitlab/v4/objects/iterations.py +4 -8
  51. gitlab/v4/objects/job_token_scope.py +18 -14
  52. gitlab/v4/objects/jobs.py +17 -32
  53. gitlab/v4/objects/keys.py +8 -11
  54. gitlab/v4/objects/labels.py +19 -30
  55. gitlab/v4/objects/ldap.py +25 -9
  56. gitlab/v4/objects/member_roles.py +102 -0
  57. gitlab/v4/objects/members.py +11 -29
  58. gitlab/v4/objects/merge_request_approvals.py +47 -38
  59. gitlab/v4/objects/merge_requests.py +30 -40
  60. gitlab/v4/objects/merge_trains.py +3 -6
  61. gitlab/v4/objects/milestones.py +23 -29
  62. gitlab/v4/objects/namespaces.py +4 -10
  63. gitlab/v4/objects/notes.py +26 -69
  64. gitlab/v4/objects/notification_settings.py +5 -14
  65. gitlab/v4/objects/package_protection_rules.py +8 -8
  66. gitlab/v4/objects/packages.py +22 -37
  67. gitlab/v4/objects/pages.py +8 -14
  68. gitlab/v4/objects/personal_access_tokens.py +7 -10
  69. gitlab/v4/objects/pipelines.py +38 -47
  70. gitlab/v4/objects/project_access_tokens.py +6 -13
  71. gitlab/v4/objects/projects.py +54 -76
  72. gitlab/v4/objects/push_rules.py +13 -15
  73. gitlab/v4/objects/registry_protection_repository_rules.py +6 -7
  74. gitlab/v4/objects/registry_protection_rules.py +7 -11
  75. gitlab/v4/objects/releases.py +6 -20
  76. gitlab/v4/objects/repositories.py +25 -34
  77. gitlab/v4/objects/resource_groups.py +10 -15
  78. gitlab/v4/objects/reviewers.py +4 -2
  79. gitlab/v4/objects/runners.py +14 -13
  80. gitlab/v4/objects/secure_files.py +8 -21
  81. gitlab/v4/objects/service_accounts.py +7 -5
  82. gitlab/v4/objects/settings.py +13 -14
  83. gitlab/v4/objects/sidekiq.py +17 -18
  84. gitlab/v4/objects/snippets.py +78 -66
  85. gitlab/v4/objects/statistics.py +8 -23
  86. gitlab/v4/objects/status_checks.py +6 -3
  87. gitlab/v4/objects/tags.py +3 -13
  88. gitlab/v4/objects/templates.py +11 -59
  89. gitlab/v4/objects/todos.py +3 -6
  90. gitlab/v4/objects/topics.py +10 -21
  91. gitlab/v4/objects/triggers.py +3 -13
  92. gitlab/v4/objects/users.py +87 -93
  93. gitlab/v4/objects/variables.py +4 -19
  94. gitlab/v4/objects/wikis.py +4 -19
  95. {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info}/METADATA +3 -2
  96. python_gitlab-6.0.0.dist-info/RECORD +107 -0
  97. {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info}/WHEEL +1 -1
  98. python_gitlab-5.5.0.dist-info/RECORD +0 -106
  99. {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info}/entry_points.txt +0 -0
  100. {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info/licenses}/AUTHORS +0 -0
  101. {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info/licenses}/COPYING +0 -0
  102. {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,4 @@
1
- from typing import Any, cast
2
-
3
- from gitlab.base import RESTManager, RESTObject
1
+ from gitlab.base import RESTObject
4
2
  from gitlab.mixins import (
5
3
  CreateMixin,
6
4
  DeleteMixin,
@@ -24,7 +22,10 @@ class ProjectPushRules(SaveMixin, ObjectDeleteMixin, RESTObject):
24
22
 
25
23
 
26
24
  class ProjectPushRulesManager(
27
- GetWithoutIdMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
25
+ GetWithoutIdMixin[ProjectPushRules],
26
+ CreateMixin[ProjectPushRules],
27
+ UpdateMixin[ProjectPushRules],
28
+ DeleteMixin[ProjectPushRules],
28
29
  ):
29
30
  _path = "/projects/{project_id}/push_rule"
30
31
  _obj_cls = ProjectPushRules
@@ -42,7 +43,7 @@ class ProjectPushRulesManager(
42
43
  "member_check",
43
44
  "prevent_secrets",
44
45
  "reject_unsigned_commits",
45
- ),
46
+ )
46
47
  )
47
48
  _update_attrs = RequiredOptional(
48
49
  optional=(
@@ -57,19 +58,19 @@ class ProjectPushRulesManager(
57
58
  "member_check",
58
59
  "prevent_secrets",
59
60
  "reject_unsigned_commits",
60
- ),
61
+ )
61
62
  )
62
63
 
63
- def get(self, **kwargs: Any) -> ProjectPushRules:
64
- return cast(ProjectPushRules, super().get(**kwargs))
65
-
66
64
 
67
65
  class GroupPushRules(SaveMixin, ObjectDeleteMixin, RESTObject):
68
66
  _id_attr = None
69
67
 
70
68
 
71
69
  class GroupPushRulesManager(
72
- GetWithoutIdMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
70
+ GetWithoutIdMixin[GroupPushRules],
71
+ CreateMixin[GroupPushRules],
72
+ UpdateMixin[GroupPushRules],
73
+ DeleteMixin[GroupPushRules],
73
74
  ):
74
75
  _path = "/groups/{group_id}/push_rule"
75
76
  _obj_cls = GroupPushRules
@@ -87,7 +88,7 @@ class GroupPushRulesManager(
87
88
  "max_file_size",
88
89
  "commit_committer_check",
89
90
  "reject_unsigned_commits",
90
- ),
91
+ )
91
92
  )
92
93
  _update_attrs = RequiredOptional(
93
94
  optional=(
@@ -102,8 +103,5 @@ class GroupPushRulesManager(
102
103
  "max_file_size",
103
104
  "commit_committer_check",
104
105
  "reject_unsigned_commits",
105
- ),
106
+ )
106
107
  )
107
-
108
- def get(self, **kwargs: Any) -> GroupPushRules:
109
- return cast(GroupPushRules, super().get(**kwargs))
@@ -1,4 +1,4 @@
1
- from gitlab.base import RESTManager, RESTObject
1
+ from gitlab.base import RESTObject
2
2
  from gitlab.mixins import CreateMixin, ListMixin, SaveMixin, UpdateMethod, UpdateMixin
3
3
  from gitlab.types import RequiredOptional
4
4
 
@@ -13,23 +13,22 @@ class ProjectRegistryRepositoryProtectionRule(SaveMixin, RESTObject):
13
13
 
14
14
 
15
15
  class ProjectRegistryRepositoryProtectionRuleManager(
16
- ListMixin, CreateMixin, UpdateMixin, RESTManager
16
+ ListMixin[ProjectRegistryRepositoryProtectionRule],
17
+ CreateMixin[ProjectRegistryRepositoryProtectionRule],
18
+ UpdateMixin[ProjectRegistryRepositoryProtectionRule],
17
19
  ):
18
20
  _path = "/projects/{project_id}/registry/protection/repository/rules"
19
21
  _obj_cls = ProjectRegistryRepositoryProtectionRule
20
22
  _from_parent_attrs = {"project_id": "id"}
21
23
  _create_attrs = RequiredOptional(
22
24
  required=("repository_path_pattern",),
23
- optional=(
24
- "minimum_access_level_for_push",
25
- "minimum_access_level_for_delete",
26
- ),
25
+ optional=("minimum_access_level_for_push", "minimum_access_level_for_delete"),
27
26
  )
28
27
  _update_attrs = RequiredOptional(
29
28
  optional=(
30
29
  "repository_path_pattern",
31
30
  "minimum_access_level_for_push",
32
31
  "minimum_access_level_for_delete",
33
- ),
32
+ )
34
33
  )
35
34
  _update_method = UpdateMethod.PATCH
@@ -1,11 +1,8 @@
1
- from gitlab.base import RESTManager, RESTObject
1
+ from gitlab.base import RESTObject
2
2
  from gitlab.mixins import CreateMixin, ListMixin, SaveMixin, UpdateMethod, UpdateMixin
3
3
  from gitlab.types import RequiredOptional
4
4
 
5
- __all__ = [
6
- "ProjectRegistryProtectionRule",
7
- "ProjectRegistryProtectionRuleManager",
8
- ]
5
+ __all__ = ["ProjectRegistryProtectionRule", "ProjectRegistryProtectionRuleManager"]
9
6
 
10
7
 
11
8
  class ProjectRegistryProtectionRule(SaveMixin, RESTObject):
@@ -13,23 +10,22 @@ class ProjectRegistryProtectionRule(SaveMixin, RESTObject):
13
10
 
14
11
 
15
12
  class ProjectRegistryProtectionRuleManager(
16
- ListMixin, CreateMixin, UpdateMixin, RESTManager
13
+ ListMixin[ProjectRegistryProtectionRule],
14
+ CreateMixin[ProjectRegistryProtectionRule],
15
+ UpdateMixin[ProjectRegistryProtectionRule],
17
16
  ):
18
17
  _path = "/projects/{project_id}/registry/protection/rules"
19
18
  _obj_cls = ProjectRegistryProtectionRule
20
19
  _from_parent_attrs = {"project_id": "id"}
21
20
  _create_attrs = RequiredOptional(
22
21
  required=("repository_path_pattern",),
23
- optional=(
24
- "minimum_access_level_for_push",
25
- "minimum_access_level_for_delete",
26
- ),
22
+ optional=("minimum_access_level_for_push", "minimum_access_level_for_delete"),
27
23
  )
28
24
  _update_attrs = RequiredOptional(
29
25
  optional=(
30
26
  "repository_path_pattern",
31
27
  "minimum_access_level_for_push",
32
28
  "minimum_access_level_for_delete",
33
- ),
29
+ )
34
30
  )
35
31
  _update_method = UpdateMethod.PATCH
@@ -1,6 +1,6 @@
1
- from typing import Any, cast, Union
1
+ from __future__ import annotations
2
2
 
3
- from gitlab.base import RESTManager, RESTObject
3
+ from gitlab.base import RESTObject
4
4
  from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
5
5
  from gitlab.types import ArrayAttribute, RequiredOptional
6
6
 
@@ -15,37 +15,28 @@ __all__ = [
15
15
  class ProjectRelease(SaveMixin, RESTObject):
16
16
  _id_attr = "tag_name"
17
17
 
18
- links: "ProjectReleaseLinkManager"
18
+ links: ProjectReleaseLinkManager
19
19
 
20
20
 
21
- class ProjectReleaseManager(CRUDMixin, RESTManager):
21
+ class ProjectReleaseManager(CRUDMixin[ProjectRelease]):
22
22
  _path = "/projects/{project_id}/releases"
23
23
  _obj_cls = ProjectRelease
24
24
  _from_parent_attrs = {"project_id": "id"}
25
25
  _create_attrs = RequiredOptional(
26
26
  required=("tag_name",), optional=("name", "description", "ref", "assets")
27
27
  )
28
- _list_filters = (
29
- "order_by",
30
- "sort",
31
- "include_html_description",
32
- )
28
+ _list_filters = ("order_by", "sort", "include_html_description")
33
29
  _update_attrs = RequiredOptional(
34
30
  optional=("name", "description", "milestones", "released_at")
35
31
  )
36
32
  _types = {"milestones": ArrayAttribute}
37
33
 
38
- def get(
39
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
40
- ) -> ProjectRelease:
41
- return cast(ProjectRelease, super().get(id=id, lazy=lazy, **kwargs))
42
-
43
34
 
44
35
  class ProjectReleaseLink(ObjectDeleteMixin, SaveMixin, RESTObject):
45
36
  pass
46
37
 
47
38
 
48
- class ProjectReleaseLinkManager(CRUDMixin, RESTManager):
39
+ class ProjectReleaseLinkManager(CRUDMixin[ProjectReleaseLink]):
49
40
  _path = "/projects/{project_id}/releases/{tag_name}/assets/links"
50
41
  _obj_cls = ProjectReleaseLink
51
42
  _from_parent_attrs = {"project_id": "project_id", "tag_name": "tag_name"}
@@ -56,8 +47,3 @@ class ProjectReleaseLinkManager(CRUDMixin, RESTManager):
56
47
  _update_attrs = RequiredOptional(
57
48
  optional=("name", "url", "filepath", "direct_asset_path", "link_type")
58
49
  )
59
-
60
- def get(
61
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
62
- ) -> ProjectReleaseLink:
63
- return cast(ProjectReleaseLink, super().get(id=id, lazy=lazy, **kwargs))
@@ -4,18 +4,9 @@ GitLab API: https://docs.gitlab.com/ee/api/repositories.html
4
4
  Currently this module only contains repository-related methods for projects.
5
5
  """
6
6
 
7
- from typing import (
8
- Any,
9
- Callable,
10
- Dict,
11
- Iterator,
12
- List,
13
- Literal,
14
- Optional,
15
- overload,
16
- TYPE_CHECKING,
17
- Union,
18
- )
7
+ from __future__ import annotations
8
+
9
+ from typing import Any, Callable, Iterator, Literal, overload, TYPE_CHECKING
19
10
 
20
11
  import requests
21
12
 
@@ -38,7 +29,7 @@ class RepositoryMixin(_RestObjectBase):
38
29
  @exc.on_http_error(exc.GitlabUpdateError)
39
30
  def update_submodule(
40
31
  self, submodule: str, branch: str, commit_sha: str, **kwargs: Any
41
- ) -> Union[Dict[str, Any], requests.Response]:
32
+ ) -> dict[str, Any] | requests.Response:
42
33
  """Update a project submodule
43
34
 
44
35
  Args:
@@ -66,14 +57,14 @@ class RepositoryMixin(_RestObjectBase):
66
57
  @exc.on_http_error(exc.GitlabGetError)
67
58
  def repository_tree(
68
59
  self, path: str = "", ref: str = "", recursive: bool = False, **kwargs: Any
69
- ) -> Union[gitlab.client.GitlabList, List[Dict[str, Any]]]:
60
+ ) -> gitlab.client.GitlabList | list[dict[str, Any]]:
70
61
  """Return a list of files in the repository.
71
62
 
72
63
  Args:
73
64
  path: Path of the top folder (/ by default)
74
65
  ref: Reference to a commit or branch
75
66
  recursive: Whether to get the tree recursively
76
- all: If True, return all the items, without pagination
67
+ get_all: If True, return all the items, without pagination
77
68
  per_page: Number of items to retrieve per request
78
69
  page: ID of the page to return (starts with page 1)
79
70
  iterator: If set to True and no pagination option is
@@ -88,7 +79,7 @@ class RepositoryMixin(_RestObjectBase):
88
79
  The representation of the tree
89
80
  """
90
81
  gl_path = f"/projects/{self.encoded_id}/repository/tree"
91
- query_data: Dict[str, Any] = {"recursive": recursive}
82
+ query_data: dict[str, Any] = {"recursive": recursive}
92
83
  if path:
93
84
  query_data["path"] = path
94
85
  if ref:
@@ -99,7 +90,7 @@ class RepositoryMixin(_RestObjectBase):
99
90
  @exc.on_http_error(exc.GitlabGetError)
100
91
  def repository_blob(
101
92
  self, sha: str, **kwargs: Any
102
- ) -> Union[Dict[str, Any], requests.Response]:
93
+ ) -> dict[str, Any] | requests.Response:
103
94
  """Return a file by blob SHA.
104
95
 
105
96
  Args:
@@ -146,7 +137,7 @@ class RepositoryMixin(_RestObjectBase):
146
137
  self,
147
138
  sha: str,
148
139
  streamed: Literal[True] = True,
149
- action: Optional[Callable[[bytes], Any]] = None,
140
+ action: Callable[[bytes], Any] | None = None,
150
141
  chunk_size: int = 1024,
151
142
  *,
152
143
  iterator: Literal[False] = False,
@@ -159,12 +150,12 @@ class RepositoryMixin(_RestObjectBase):
159
150
  self,
160
151
  sha: str,
161
152
  streamed: bool = False,
162
- action: Optional[Callable[..., Any]] = None,
153
+ action: Callable[..., Any] | None = None,
163
154
  chunk_size: int = 1024,
164
155
  *,
165
156
  iterator: bool = False,
166
157
  **kwargs: Any,
167
- ) -> Optional[Union[bytes, Iterator[Any]]]:
158
+ ) -> bytes | Iterator[Any] | None:
168
159
  """Return the raw file contents for a blob.
169
160
 
170
161
  Args:
@@ -200,7 +191,7 @@ class RepositoryMixin(_RestObjectBase):
200
191
  @exc.on_http_error(exc.GitlabGetError)
201
192
  def repository_compare(
202
193
  self, from_: str, to: str, **kwargs: Any
203
- ) -> Union[Dict[str, Any], requests.Response]:
194
+ ) -> dict[str, Any] | requests.Response:
204
195
  """Return a diff between two branches/commits.
205
196
 
206
197
  Args:
@@ -223,11 +214,11 @@ class RepositoryMixin(_RestObjectBase):
223
214
  @exc.on_http_error(exc.GitlabGetError)
224
215
  def repository_contributors(
225
216
  self, **kwargs: Any
226
- ) -> Union[gitlab.client.GitlabList, List[Dict[str, Any]]]:
217
+ ) -> gitlab.client.GitlabList | list[dict[str, Any]]:
227
218
  """Return a list of contributors for the project.
228
219
 
229
220
  Args:
230
- all: If True, return all the items, without pagination
221
+ get_all: If True, return all the items, without pagination
231
222
  per_page: Number of items to retrieve per request
232
223
  page: ID of the page to return (starts with page 1)
233
224
  iterator: If set to True and no pagination option is
@@ -247,7 +238,7 @@ class RepositoryMixin(_RestObjectBase):
247
238
  @overload
248
239
  def repository_archive(
249
240
  self,
250
- sha: Optional[str] = None,
241
+ sha: str | None = None,
251
242
  streamed: Literal[False] = False,
252
243
  action: None = None,
253
244
  chunk_size: int = 1024,
@@ -259,7 +250,7 @@ class RepositoryMixin(_RestObjectBase):
259
250
  @overload
260
251
  def repository_archive(
261
252
  self,
262
- sha: Optional[str] = None,
253
+ sha: str | None = None,
263
254
  streamed: bool = False,
264
255
  action: None = None,
265
256
  chunk_size: int = 1024,
@@ -271,9 +262,9 @@ class RepositoryMixin(_RestObjectBase):
271
262
  @overload
272
263
  def repository_archive(
273
264
  self,
274
- sha: Optional[str] = None,
265
+ sha: str | None = None,
275
266
  streamed: Literal[True] = True,
276
- action: Optional[Callable[[bytes], Any]] = None,
267
+ action: Callable[[bytes], Any] | None = None,
277
268
  chunk_size: int = 1024,
278
269
  *,
279
270
  iterator: Literal[False] = False,
@@ -284,16 +275,16 @@ class RepositoryMixin(_RestObjectBase):
284
275
  @exc.on_http_error(exc.GitlabListError)
285
276
  def repository_archive(
286
277
  self,
287
- sha: Optional[str] = None,
278
+ sha: str | None = None,
288
279
  streamed: bool = False,
289
- action: Optional[Callable[..., Any]] = None,
280
+ action: Callable[..., Any] | None = None,
290
281
  chunk_size: int = 1024,
291
- format: Optional[str] = None,
292
- path: Optional[str] = None,
282
+ format: str | None = None,
283
+ path: str | None = None,
293
284
  *,
294
285
  iterator: bool = False,
295
286
  **kwargs: Any,
296
- ) -> Optional[Union[bytes, Iterator[Any]]]:
287
+ ) -> bytes | Iterator[Any] | None:
297
288
  """Return an archive of the repository.
298
289
 
299
290
  Args:
@@ -337,8 +328,8 @@ class RepositoryMixin(_RestObjectBase):
337
328
  @cli.register_custom_action(cls_names="Project", required=("refs",))
338
329
  @exc.on_http_error(exc.GitlabGetError)
339
330
  def repository_merge_base(
340
- self, refs: List[str], **kwargs: Any
341
- ) -> Union[Dict[str, Any], requests.Response]:
331
+ self, refs: list[str], **kwargs: Any
332
+ ) -> dict[str, Any] | requests.Response:
342
333
  """Return a diff between two branches/commits.
343
334
 
344
335
  Args:
@@ -1,6 +1,6 @@
1
- from typing import Any, cast, Union
1
+ from __future__ import annotations
2
2
 
3
- from gitlab.base import RESTManager, RESTObject
3
+ from gitlab.base import RESTObject
4
4
  from gitlab.mixins import ListMixin, RetrieveMixin, SaveMixin, UpdateMixin
5
5
  from gitlab.types import RequiredOptional
6
6
 
@@ -15,31 +15,26 @@ __all__ = [
15
15
  class ProjectResourceGroup(SaveMixin, RESTObject):
16
16
  _id_attr = "key"
17
17
 
18
- upcoming_jobs: "ProjectResourceGroupUpcomingJobManager"
18
+ upcoming_jobs: ProjectResourceGroupUpcomingJobManager
19
19
 
20
20
 
21
- class ProjectResourceGroupManager(RetrieveMixin, UpdateMixin, RESTManager):
21
+ class ProjectResourceGroupManager(
22
+ RetrieveMixin[ProjectResourceGroup], UpdateMixin[ProjectResourceGroup]
23
+ ):
22
24
  _path = "/projects/{project_id}/resource_groups"
23
25
  _obj_cls = ProjectResourceGroup
24
26
  _from_parent_attrs = {"project_id": "id"}
25
- _list_filters = (
26
- "order_by",
27
- "sort",
28
- "include_html_description",
29
- )
27
+ _list_filters = ("order_by", "sort", "include_html_description")
30
28
  _update_attrs = RequiredOptional(optional=("process_mode",))
31
29
 
32
- def get(
33
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
34
- ) -> ProjectResourceGroup:
35
- return cast(ProjectResourceGroup, super().get(id=id, lazy=lazy, **kwargs))
36
-
37
30
 
38
31
  class ProjectResourceGroupUpcomingJob(RESTObject):
39
32
  pass
40
33
 
41
34
 
42
- class ProjectResourceGroupUpcomingJobManager(ListMixin, RESTManager):
35
+ class ProjectResourceGroupUpcomingJobManager(
36
+ ListMixin[ProjectResourceGroupUpcomingJob]
37
+ ):
43
38
  _path = "/projects/{project_id}/resource_groups/{resource_group_key}/upcoming_jobs"
44
39
  _obj_cls = ProjectResourceGroupUpcomingJob
45
40
  _from_parent_attrs = {"project_id": "project_id", "resource_group_key": "key"}
@@ -1,4 +1,4 @@
1
- from gitlab.base import RESTManager, RESTObject
1
+ from gitlab.base import RESTObject
2
2
  from gitlab.mixins import ListMixin
3
3
 
4
4
  __all__ = [
@@ -11,7 +11,9 @@ class ProjectMergeRequestReviewerDetail(RESTObject):
11
11
  pass
12
12
 
13
13
 
14
- class ProjectMergeRequestReviewerDetailManager(ListMixin, RESTManager):
14
+ class ProjectMergeRequestReviewerDetailManager(
15
+ ListMixin[ProjectMergeRequestReviewerDetail]
16
+ ):
15
17
  _path = "/projects/{project_id}/merge_requests/{mr_iid}/reviewers"
16
18
  _obj_cls = ProjectMergeRequestReviewerDetail
17
19
  _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"}
@@ -1,9 +1,11 @@
1
- from typing import Any, cast, List, Optional, Union
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
2
4
 
3
5
  from gitlab import cli
4
6
  from gitlab import exceptions as exc
5
7
  from gitlab import types
6
- from gitlab.base import RESTManager, RESTObject
8
+ from gitlab.base import RESTObject
7
9
  from gitlab.mixins import (
8
10
  CreateMixin,
9
11
  CRUDMixin,
@@ -32,7 +34,7 @@ class RunnerJob(RESTObject):
32
34
  pass
33
35
 
34
36
 
35
- class RunnerJobManager(ListMixin, RESTManager):
37
+ class RunnerJobManager(ListMixin[RunnerJob]):
36
38
  _path = "/runners/{runner_id}/jobs"
37
39
  _obj_cls = RunnerJob
38
40
  _from_parent_attrs = {"runner_id": "id"}
@@ -44,7 +46,7 @@ class Runner(SaveMixin, ObjectDeleteMixin, RESTObject):
44
46
  _repr_attr = "description"
45
47
 
46
48
 
47
- class RunnerManager(CRUDMixin, RESTManager):
49
+ class RunnerManager(CRUDMixin[Runner]):
48
50
  _path = "/runners"
49
51
  _obj_cls = Runner
50
52
  _create_attrs = RequiredOptional(
@@ -69,20 +71,20 @@ class RunnerManager(CRUDMixin, RESTManager):
69
71
  "locked",
70
72
  "access_level",
71
73
  "maximum_timeout",
72
- ),
74
+ )
73
75
  )
74
76
  _list_filters = ("scope", "type", "status", "paused", "tag_list")
75
77
  _types = {"tag_list": types.CommaSeparatedListAttribute}
76
78
 
77
79
  @cli.register_custom_action(cls_names="RunnerManager", optional=("scope",))
78
80
  @exc.on_http_error(exc.GitlabListError)
79
- def all(self, scope: Optional[str] = None, **kwargs: Any) -> List[Runner]:
81
+ def all(self, scope: str | None = None, **kwargs: Any) -> list[Runner]:
80
82
  """List all the runners.
81
83
 
82
84
  Args:
83
85
  scope: The scope of runners to show, one of: specific,
84
86
  shared, active, paused, online
85
- all: If True, return all the items, without pagination
87
+ get_all: If True, return all the items, without pagination
86
88
  per_page: Number of items to retrieve per request
87
89
  page: ID of the page to return (starts with page 1)
88
90
  iterator: If set to True and no pagination option is
@@ -120,15 +122,12 @@ class RunnerManager(CRUDMixin, RESTManager):
120
122
  post_data = {"token": token}
121
123
  self.gitlab.http_post(path, post_data=post_data, **kwargs)
122
124
 
123
- def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Runner:
124
- return cast(Runner, super().get(id=id, lazy=lazy, **kwargs))
125
-
126
125
 
127
126
  class RunnerAll(RESTObject):
128
127
  _repr_attr = "description"
129
128
 
130
129
 
131
- class RunnerAllManager(ListMixin, RESTManager):
130
+ class RunnerAllManager(ListMixin[RunnerAll]):
132
131
  _path = "/runners/all"
133
132
  _obj_cls = RunnerAll
134
133
  _list_filters = ("scope", "type", "status", "paused", "tag_list")
@@ -139,7 +138,7 @@ class GroupRunner(RESTObject):
139
138
  pass
140
139
 
141
140
 
142
- class GroupRunnerManager(ListMixin, RESTManager):
141
+ class GroupRunnerManager(ListMixin[GroupRunner]):
143
142
  _path = "/groups/{group_id}/runners"
144
143
  _obj_cls = GroupRunner
145
144
  _from_parent_attrs = {"group_id": "id"}
@@ -152,7 +151,9 @@ class ProjectRunner(ObjectDeleteMixin, RESTObject):
152
151
  pass
153
152
 
154
153
 
155
- class ProjectRunnerManager(CreateMixin, DeleteMixin, ListMixin, RESTManager):
154
+ class ProjectRunnerManager(
155
+ CreateMixin[ProjectRunner], DeleteMixin[ProjectRunner], ListMixin[ProjectRunner]
156
+ ):
156
157
  _path = "/projects/{project_id}/runners"
157
158
  _obj_cls = ProjectRunner
158
159
  _from_parent_attrs = {"project_id": "id"}
@@ -3,24 +3,16 @@ GitLab API:
3
3
  https://docs.gitlab.com/ee/api/secure_files.html
4
4
  """
5
5
 
6
- from typing import (
7
- Any,
8
- Callable,
9
- cast,
10
- Iterator,
11
- Literal,
12
- Optional,
13
- overload,
14
- TYPE_CHECKING,
15
- Union,
16
- )
6
+ from __future__ import annotations
7
+
8
+ from typing import Any, Callable, Iterator, Literal, overload, TYPE_CHECKING
17
9
 
18
10
  import requests
19
11
 
20
12
  from gitlab import cli
21
13
  from gitlab import exceptions as exc
22
14
  from gitlab import utils
23
- from gitlab.base import RESTManager, RESTObject
15
+ from gitlab.base import RESTObject
24
16
  from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin
25
17
  from gitlab.types import FileAttribute, RequiredOptional
26
18
 
@@ -54,7 +46,7 @@ class ProjectSecureFile(ObjectDeleteMixin, RESTObject):
54
46
  def download(
55
47
  self,
56
48
  streamed: Literal[True] = True,
57
- action: Optional[Callable[[bytes], Any]] = None,
49
+ action: Callable[[bytes], Any] | None = None,
58
50
  chunk_size: int = 1024,
59
51
  *,
60
52
  iterator: Literal[False] = False,
@@ -66,12 +58,12 @@ class ProjectSecureFile(ObjectDeleteMixin, RESTObject):
66
58
  def download(
67
59
  self,
68
60
  streamed: bool = False,
69
- action: Optional[Callable[[bytes], Any]] = None,
61
+ action: Callable[[bytes], Any] | None = None,
70
62
  chunk_size: int = 1024,
71
63
  *,
72
64
  iterator: bool = False,
73
65
  **kwargs: Any,
74
- ) -> Optional[Union[bytes, Iterator[Any]]]:
66
+ ) -> bytes | Iterator[Any] | None:
75
67
  """Download the secure file.
76
68
 
77
69
  Args:
@@ -102,14 +94,9 @@ class ProjectSecureFile(ObjectDeleteMixin, RESTObject):
102
94
  )
103
95
 
104
96
 
105
- class ProjectSecureFileManager(NoUpdateMixin, RESTManager):
97
+ class ProjectSecureFileManager(NoUpdateMixin[ProjectSecureFile]):
106
98
  _path = "/projects/{project_id}/secure_files"
107
99
  _obj_cls = ProjectSecureFile
108
100
  _from_parent_attrs = {"project_id": "id"}
109
101
  _create_attrs = RequiredOptional(required=("name", "file"))
110
102
  _types = {"file": FileAttribute}
111
-
112
- def get(
113
- self, id: Union[str, int], lazy: bool = False, **kwargs: Any
114
- ) -> ProjectSecureFile:
115
- return cast(ProjectSecureFile, super().get(id=id, lazy=lazy, **kwargs))
@@ -1,4 +1,4 @@
1
- from gitlab.base import RESTManager, RESTObject
1
+ from gitlab.base import RESTObject
2
2
  from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin
3
3
  from gitlab.types import RequiredOptional
4
4
 
@@ -9,10 +9,12 @@ class GroupServiceAccount(ObjectDeleteMixin, RESTObject):
9
9
  pass
10
10
 
11
11
 
12
- class GroupServiceAccountManager(CreateMixin, DeleteMixin, ListMixin, RESTManager):
12
+ class GroupServiceAccountManager(
13
+ CreateMixin[GroupServiceAccount],
14
+ DeleteMixin[GroupServiceAccount],
15
+ ListMixin[GroupServiceAccount],
16
+ ):
13
17
  _path = "/groups/{group_id}/service_accounts"
14
18
  _obj_cls = GroupServiceAccount
15
19
  _from_parent_attrs = {"group_id": "id"}
16
- _create_attrs = RequiredOptional(
17
- optional=("name", "username"),
18
- )
20
+ _create_attrs = RequiredOptional(optional=("name", "username"))