From 6efad645a66c0ea181ad09ba8eacde12476368c8 Mon Sep 17 00:00:00 2001 From: Igor Ponomarev Date: Wed, 29 Jan 2025 17:09:03 +0000 Subject: [PATCH] chore: Remove trivial get methods in preparation for generic Get mixin Currently because the Get mixin is not generic every subclass has to implement its own `get` methods to type hint `get` method return beoynd the basic RESTObject. The upcoming PR will change Get mixin to use generics. This means it will be able to type hint the corresponding `_obj_cls` and no `get` method would need to be redefined. Because removing existing `get` methods modifies a lot of files split it in to a separate commit. Also remove the `tests/unit/meta/test_ensure_type_hints.py` file because testing subclasses for `get` methods is no longer relevant. Signed-off-by: Igor Ponomarev --- gitlab/client.py | 5 +- gitlab/v4/objects/appearance.py | 5 +- gitlab/v4/objects/audit_events.py | 15 -- gitlab/v4/objects/award_emojis.py | 48 ------- gitlab/v4/objects/badges.py | 10 -- gitlab/v4/objects/boards.py | 20 --- gitlab/v4/objects/branches.py | 12 -- gitlab/v4/objects/broadcast_messages.py | 7 - gitlab/v4/objects/bulk_imports.py | 10 -- gitlab/v4/objects/ci_lint.py | 5 +- gitlab/v4/objects/cluster_agents.py | 7 - gitlab/v4/objects/clusters.py | 12 +- gitlab/v4/objects/commits.py | 5 - gitlab/v4/objects/container_registry.py | 12 +- gitlab/v4/objects/custom_attributes.py | 17 --- gitlab/v4/objects/deploy_keys.py | 5 +- gitlab/v4/objects/deploy_tokens.py | 12 -- gitlab/v4/objects/deployments.py | 7 +- gitlab/v4/objects/discussions.py | 24 ---- gitlab/v4/objects/draft_notes.py | 9 +- gitlab/v4/objects/environments.py | 14 +- gitlab/v4/objects/epics.py | 5 +- gitlab/v4/objects/events.py | 68 ---------- gitlab/v4/objects/export_import.py | 14 -- gitlab/v4/objects/geo_nodes.py | 5 +- gitlab/v4/objects/group_access_tokens.py | 7 - gitlab/v4/objects/groups.py | 10 +- gitlab/v4/objects/hooks.py | 13 -- gitlab/v4/objects/integrations.py | 12 +- gitlab/v4/objects/invitations.py | 12 +- gitlab/v4/objects/issues.py | 10 +- gitlab/v4/objects/job_token_scope.py | 5 +- gitlab/v4/objects/jobs.py | 4 - gitlab/v4/objects/labels.py | 10 +- gitlab/v4/objects/members.py | 22 --- gitlab/v4/objects/merge_request_approvals.py | 28 +--- gitlab/v4/objects/merge_requests.py | 12 +- gitlab/v4/objects/milestones.py | 12 +- gitlab/v4/objects/namespaces.py | 5 +- gitlab/v4/objects/notes.py | 58 -------- gitlab/v4/objects/notification_settings.py | 11 -- gitlab/v4/objects/packages.py | 6 - gitlab/v4/objects/pages.py | 10 -- gitlab/v4/objects/personal_access_tokens.py | 7 - gitlab/v4/objects/pipelines.py | 16 --- gitlab/v4/objects/project_access_tokens.py | 7 - gitlab/v4/objects/projects.py | 9 -- gitlab/v4/objects/push_rules.py | 8 -- gitlab/v4/objects/releases.py | 12 -- gitlab/v4/objects/resource_groups.py | 7 - gitlab/v4/objects/runners.py | 5 +- gitlab/v4/objects/secure_files.py | 6 - gitlab/v4/objects/settings.py | 5 +- gitlab/v4/objects/snippets.py | 9 -- gitlab/v4/objects/statistics.py | 17 --- gitlab/v4/objects/tags.py | 10 -- gitlab/v4/objects/templates.py | 48 ------- gitlab/v4/objects/topics.py | 5 +- gitlab/v4/objects/triggers.py | 7 - gitlab/v4/objects/users.py | 46 ------- gitlab/v4/objects/variables.py | 15 -- gitlab/v4/objects/wikis.py | 10 -- tests/functional/api/test_merge_requests.py | 2 +- tests/unit/meta/test_ensure_type_hints.py | 136 ------------------- 64 files changed, 27 insertions(+), 960 deletions(-) delete mode 100644 tests/unit/meta/test_ensure_type_hints.py diff --git a/gitlab/client.py b/gitlab/client.py index 87b324c34..45540ad22 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -397,10 +397,11 @@ def auth(self) -> None: The `user` attribute will hold a `gitlab.objects.CurrentUser` object on success. """ - self.user = self._objects.CurrentUserManager(self).get() + # pylint: disable=line-too-long + self.user = self._objects.CurrentUserManager(self).get() # type: ignore[assignment] if hasattr(self.user, "web_url") and hasattr(self.user, "username"): - self._check_url(self.user.web_url, path=self.user.username) + self._check_url(self.user.web_url, path=self.user.username) # type: ignore[union-attr] def version(self) -> Tuple[str, str]: """Returns the version and revision of the gitlab server. diff --git a/gitlab/v4/objects/appearance.py b/gitlab/v4/objects/appearance.py index f86bf797c..e55046014 100644 --- a/gitlab/v4/objects/appearance.py +++ b/gitlab/v4/objects/appearance.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, Optional, Union +from typing import Any, Dict, Optional, Union from gitlab import exceptions as exc from gitlab.base import RESTManager, RESTObject @@ -58,6 +58,3 @@ def update( new_data = new_data or {} data = new_data.copy() return super().update(id, data, **kwargs) - - def get(self, **kwargs: Any) -> ApplicationAppearance: - return cast(ApplicationAppearance, super().get(**kwargs)) diff --git a/gitlab/v4/objects/audit_events.py b/gitlab/v4/objects/audit_events.py index fb7c3ffe4..c3ff35498 100644 --- a/gitlab/v4/objects/audit_events.py +++ b/gitlab/v4/objects/audit_events.py @@ -3,8 +3,6 @@ https://docs.gitlab.com/ee/api/audit_events.html """ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import RetrieveMixin @@ -29,9 +27,6 @@ class AuditEventManager(RetrieveMixin, RESTManager): _obj_cls = AuditEvent _list_filters = ("created_after", "created_before", "entity_type", "entity_id") - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> AuditEvent: - return cast(AuditEvent, super().get(id=id, lazy=lazy, **kwargs)) - class GroupAuditEvent(RESTObject): _id_attr = "id" @@ -43,11 +38,6 @@ class GroupAuditEventManager(RetrieveMixin, RESTManager): _from_parent_attrs = {"group_id": "id"} _list_filters = ("created_after", "created_before") - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupAuditEvent: - return cast(GroupAuditEvent, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectAuditEvent(RESTObject): _id_attr = "id" @@ -59,11 +49,6 @@ class ProjectAuditEventManager(RetrieveMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _list_filters = ("created_after", "created_before") - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectAuditEvent: - return cast(ProjectAuditEvent, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectAudit(ProjectAuditEvent): pass diff --git a/gitlab/v4/objects/award_emojis.py b/gitlab/v4/objects/award_emojis.py index cddf97f1b..f9153e726 100644 --- a/gitlab/v4/objects/award_emojis.py +++ b/gitlab/v4/objects/award_emojis.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin from gitlab.types import RequiredOptional @@ -34,11 +32,6 @@ class GroupEpicAwardEmojiManager(NoUpdateMixin, RESTManager): _from_parent_attrs = {"group_id": "group_id", "epic_iid": "iid"} _create_attrs = RequiredOptional(required=("name",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupEpicAwardEmoji: - return cast(GroupEpicAwardEmoji, super().get(id=id, lazy=lazy, **kwargs)) - class GroupEpicNoteAwardEmoji(ObjectDeleteMixin, RESTObject): pass @@ -54,11 +47,6 @@ class GroupEpicNoteAwardEmojiManager(NoUpdateMixin, RESTManager): } _create_attrs = RequiredOptional(required=("name",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupEpicNoteAwardEmoji: - return cast(GroupEpicNoteAwardEmoji, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectIssueAwardEmoji(ObjectDeleteMixin, RESTObject): pass @@ -70,11 +58,6 @@ class ProjectIssueAwardEmojiManager(NoUpdateMixin, RESTManager): _from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"} _create_attrs = RequiredOptional(required=("name",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueAwardEmoji: - return cast(ProjectIssueAwardEmoji, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectIssueNoteAwardEmoji(ObjectDeleteMixin, RESTObject): pass @@ -90,11 +73,6 @@ class ProjectIssueNoteAwardEmojiManager(NoUpdateMixin, RESTManager): } _create_attrs = RequiredOptional(required=("name",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueNoteAwardEmoji: - return cast(ProjectIssueNoteAwardEmoji, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectMergeRequestAwardEmoji(ObjectDeleteMixin, RESTObject): pass @@ -106,13 +84,6 @@ class ProjectMergeRequestAwardEmojiManager(NoUpdateMixin, RESTManager): _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"} _create_attrs = RequiredOptional(required=("name",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestAwardEmoji: - return cast( - ProjectMergeRequestAwardEmoji, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectMergeRequestNoteAwardEmoji(ObjectDeleteMixin, RESTObject): pass @@ -128,13 +99,6 @@ class ProjectMergeRequestNoteAwardEmojiManager(NoUpdateMixin, RESTManager): } _create_attrs = RequiredOptional(required=("name",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestNoteAwardEmoji: - return cast( - ProjectMergeRequestNoteAwardEmoji, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectSnippetAwardEmoji(ObjectDeleteMixin, RESTObject): pass @@ -146,11 +110,6 @@ class ProjectSnippetAwardEmojiManager(NoUpdateMixin, RESTManager): _from_parent_attrs = {"project_id": "project_id", "snippet_id": "id"} _create_attrs = RequiredOptional(required=("name",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectSnippetAwardEmoji: - return cast(ProjectSnippetAwardEmoji, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectSnippetNoteAwardEmoji(ObjectDeleteMixin, RESTObject): pass @@ -165,10 +124,3 @@ class ProjectSnippetNoteAwardEmojiManager(NoUpdateMixin, RESTManager): "note_id": "id", } _create_attrs = RequiredOptional(required=("name",)) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectSnippetNoteAwardEmoji: - return cast( - ProjectSnippetNoteAwardEmoji, super().get(id=id, lazy=lazy, **kwargs) - ) diff --git a/gitlab/v4/objects/badges.py b/gitlab/v4/objects/badges.py index 3df5d0b28..f1b262569 100644 --- a/gitlab/v4/objects/badges.py +++ b/gitlab/v4/objects/badges.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import BadgeRenderMixin, CRUDMixin, ObjectDeleteMixin, SaveMixin from gitlab.types import RequiredOptional @@ -23,9 +21,6 @@ class GroupBadgeManager(BadgeRenderMixin, CRUDMixin, RESTManager): _create_attrs = RequiredOptional(required=("link_url", "image_url")) _update_attrs = RequiredOptional(optional=("link_url", "image_url")) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupBadge: - return cast(GroupBadge, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectBadge(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -37,8 +32,3 @@ class ProjectBadgeManager(BadgeRenderMixin, CRUDMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("link_url", "image_url")) _update_attrs = RequiredOptional(optional=("link_url", "image_url")) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectBadge: - return cast(ProjectBadge, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/boards.py b/gitlab/v4/objects/boards.py index c5243db8f..e19ae3335 100644 --- a/gitlab/v4/objects/boards.py +++ b/gitlab/v4/objects/boards.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin from gitlab.types import RequiredOptional @@ -29,11 +27,6 @@ class GroupBoardListManager(CRUDMixin, RESTManager): ) _update_attrs = RequiredOptional(required=("position",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupBoardList: - return cast(GroupBoardList, super().get(id=id, lazy=lazy, **kwargs)) - class GroupBoard(SaveMixin, ObjectDeleteMixin, RESTObject): lists: GroupBoardListManager @@ -45,9 +38,6 @@ class GroupBoardManager(CRUDMixin, RESTManager): _from_parent_attrs = {"group_id": "id"} _create_attrs = RequiredOptional(required=("name",)) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupBoard: - return cast(GroupBoard, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectBoardList(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -62,11 +52,6 @@ class ProjectBoardListManager(CRUDMixin, RESTManager): ) _update_attrs = RequiredOptional(required=("position",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectBoardList: - return cast(ProjectBoardList, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectBoard(SaveMixin, ObjectDeleteMixin, RESTObject): lists: ProjectBoardListManager @@ -77,8 +62,3 @@ class ProjectBoardManager(CRUDMixin, RESTManager): _obj_cls = ProjectBoard _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("name",)) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectBoard: - return cast(ProjectBoard, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/branches.py b/gitlab/v4/objects/branches.py index de7a046d3..22d112e2a 100644 --- a/gitlab/v4/objects/branches.py +++ b/gitlab/v4/objects/branches.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CRUDMixin, @@ -28,11 +26,6 @@ class ProjectBranchManager(NoUpdateMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("branch", "ref")) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectBranch: - return cast(ProjectBranch, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectProtectedBranch(SaveMixin, ObjectDeleteMixin, RESTObject): _id_attr = "name" @@ -56,8 +49,3 @@ class ProjectProtectedBranchManager(CRUDMixin, RESTManager): ), ) _update_method = UpdateMethod.PATCH - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectProtectedBranch: - return cast(ProjectProtectedBranch, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/broadcast_messages.py b/gitlab/v4/objects/broadcast_messages.py index e3bda6871..492c65bf2 100644 --- a/gitlab/v4/objects/broadcast_messages.py +++ b/gitlab/v4/objects/broadcast_messages.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin from gitlab.types import ArrayAttribute, RequiredOptional @@ -33,8 +31,3 @@ class BroadcastMessageManager(CRUDMixin, RESTManager): ) ) _types = {"target_access_levels": ArrayAttribute} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> BroadcastMessage: - return cast(BroadcastMessage, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/bulk_imports.py b/gitlab/v4/objects/bulk_imports.py index e8ef74f22..dfbee1880 100644 --- a/gitlab/v4/objects/bulk_imports.py +++ b/gitlab/v4/objects/bulk_imports.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, ListMixin, RefreshMixin, RetrieveMixin from gitlab.types import RequiredOptional @@ -24,9 +22,6 @@ class BulkImportManager(CreateMixin, RetrieveMixin, RESTManager): _create_attrs = RequiredOptional(required=("configuration", "entities")) _list_filters = ("sort", "status") - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> BulkImport: - return cast(BulkImport, super().get(id=id, lazy=lazy, **kwargs)) - class BulkImportEntity(RefreshMixin, RESTObject): pass @@ -38,11 +33,6 @@ class BulkImportEntityManager(RetrieveMixin, RESTManager): _from_parent_attrs = {"bulk_import_id": "id"} _list_filters = ("sort", "status") - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> BulkImportEntity: - return cast(BulkImportEntity, super().get(id=id, lazy=lazy, **kwargs)) - class BulkImportAllEntity(RESTObject): pass diff --git a/gitlab/v4/objects/ci_lint.py b/gitlab/v4/objects/ci_lint.py index e00da156a..5fa146fac 100644 --- a/gitlab/v4/objects/ci_lint.py +++ b/gitlab/v4/objects/ci_lint.py @@ -3,7 +3,7 @@ https://docs.gitlab.com/ee/api/lint.html """ -from typing import Any, cast +from typing import Any from gitlab.base import RESTManager, RESTObject from gitlab.cli import register_custom_action @@ -59,9 +59,6 @@ class ProjectCiLintManager(GetWithoutIdMixin, CreateMixin, RESTManager): required=("content",), optional=("dry_run", "include_jobs", "ref") ) - def get(self, **kwargs: Any) -> ProjectCiLint: - return cast(ProjectCiLint, super().get(**kwargs)) - @register_custom_action( cls_names="ProjectCiLintManager", required=("content",), diff --git a/gitlab/v4/objects/cluster_agents.py b/gitlab/v4/objects/cluster_agents.py index bac3eb266..c53c8ab5f 100644 --- a/gitlab/v4/objects/cluster_agents.py +++ b/gitlab/v4/objects/cluster_agents.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin, SaveMixin from gitlab.types import RequiredOptional @@ -19,8 +17,3 @@ class ProjectClusterAgentManager(NoUpdateMixin, RESTManager): _obj_cls = ProjectClusterAgent _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("name",)) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectClusterAgent: - return cast(ProjectClusterAgent, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/clusters.py b/gitlab/v4/objects/clusters.py index d51a97a7b..ead012c61 100644 --- a/gitlab/v4/objects/clusters.py +++ b/gitlab/v4/objects/clusters.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, Optional, Union +from typing import Any, cast, Dict, Optional from gitlab import exceptions as exc from gitlab.base import RESTManager, RESTObject @@ -58,11 +58,6 @@ def create( path = f"{self.path}/user" return cast(GroupCluster, CreateMixin.create(self, data, path=path, **kwargs)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupCluster: - return cast(GroupCluster, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectCluster(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -108,8 +103,3 @@ def create( """ path = f"{self.path}/user" return cast(ProjectCluster, CreateMixin.create(self, data, path=path, **kwargs)) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectCluster: - return cast(ProjectCluster, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/commits.py b/gitlab/v4/objects/commits.py index e7c8164b7..935a3bc28 100644 --- a/gitlab/v4/objects/commits.py +++ b/gitlab/v4/objects/commits.py @@ -189,11 +189,6 @@ class ProjectCommitManager(RetrieveMixin, CreateMixin, RESTManager): "trailers", ) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectCommit: - return cast(ProjectCommit, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectCommitComment(RESTObject): _id_attr = None diff --git a/gitlab/v4/objects/container_registry.py b/gitlab/v4/objects/container_registry.py index 76154053e..08b3ca072 100644 --- a/gitlab/v4/objects/container_registry.py +++ b/gitlab/v4/objects/container_registry.py @@ -1,4 +1,4 @@ -from typing import Any, cast, TYPE_CHECKING, Union +from typing import Any, TYPE_CHECKING from gitlab import cli from gitlab import exceptions as exc @@ -70,11 +70,6 @@ def delete_in_bulk(self, name_regex_delete: str, **kwargs: Any) -> None: assert self.path is not None self.gitlab.http_delete(self.path, query_data=data, **kwargs) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectRegistryTag: - return cast(ProjectRegistryTag, super().get(id=id, lazy=lazy, **kwargs)) - class GroupRegistryRepositoryManager(ListMixin, RESTManager): _path = "/groups/{group_id}/registry/repositories" @@ -89,8 +84,3 @@ class RegistryRepository(RESTObject): class RegistryRepositoryManager(GetMixin, RESTManager): _path = "/registry/repositories" _obj_cls = RegistryRepository - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> RegistryRepository: - return cast(RegistryRepository, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/custom_attributes.py b/gitlab/v4/objects/custom_attributes.py index d06161474..aed19652f 100644 --- a/gitlab/v4/objects/custom_attributes.py +++ b/gitlab/v4/objects/custom_attributes.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import DeleteMixin, ObjectDeleteMixin, RetrieveMixin, SetMixin @@ -22,11 +20,6 @@ class GroupCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, RESTMana _obj_cls = GroupCustomAttribute _from_parent_attrs = {"group_id": "id"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupCustomAttribute: - return cast(GroupCustomAttribute, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectCustomAttribute(ObjectDeleteMixin, RESTObject): _id_attr = "key" @@ -37,11 +30,6 @@ class ProjectCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, RESTMa _obj_cls = ProjectCustomAttribute _from_parent_attrs = {"project_id": "id"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectCustomAttribute: - return cast(ProjectCustomAttribute, super().get(id=id, lazy=lazy, **kwargs)) - class UserCustomAttribute(ObjectDeleteMixin, RESTObject): _id_attr = "key" @@ -51,8 +39,3 @@ class UserCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, RESTManag _path = "/users/{user_id}/custom_attributes" _obj_cls = UserCustomAttribute _from_parent_attrs = {"user_id": "id"} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> UserCustomAttribute: - return cast(UserCustomAttribute, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/deploy_keys.py b/gitlab/v4/objects/deploy_keys.py index 40468eff0..44fa51007 100644 --- a/gitlab/v4/objects/deploy_keys.py +++ b/gitlab/v4/objects/deploy_keys.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, Union +from typing import Any, Dict, Union import requests @@ -61,6 +61,3 @@ def enable( """ path = f"{self.path}/{key_id}/enable" return self.gitlab.http_post(path, **kwargs) - - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> ProjectKey: - return cast(ProjectKey, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/deploy_tokens.py b/gitlab/v4/objects/deploy_tokens.py index e35bf22c5..4c283789d 100644 --- a/gitlab/v4/objects/deploy_tokens.py +++ b/gitlab/v4/objects/deploy_tokens.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab import types from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( @@ -51,11 +49,6 @@ class GroupDeployTokenManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManag _list_filters = ("scopes",) _types = {"scopes": types.ArrayAttribute} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupDeployToken: - return cast(GroupDeployToken, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectDeployToken(ObjectDeleteMixin, RESTObject): pass @@ -77,8 +70,3 @@ class ProjectDeployTokenManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTMan ) _list_filters = ("scopes",) _types = {"scopes": types.ArrayAttribute} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectDeployToken: - return cast(ProjectDeployToken, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/deployments.py b/gitlab/v4/objects/deployments.py index c906fa269..7e080d082 100644 --- a/gitlab/v4/objects/deployments.py +++ b/gitlab/v4/objects/deployments.py @@ -3,7 +3,7 @@ https://docs.gitlab.com/ee/api/deployments.html """ -from typing import Any, cast, Dict, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, Optional, TYPE_CHECKING from gitlab import cli from gitlab import exceptions as exc @@ -82,8 +82,3 @@ class ProjectDeploymentManager(RetrieveMixin, CreateMixin, UpdateMixin, RESTMana _create_attrs = RequiredOptional( required=("sha", "ref", "tag", "status", "environment") ) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectDeployment: - return cast(ProjectDeployment, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/discussions.py b/gitlab/v4/objects/discussions.py index 9cfce7211..abcd40108 100644 --- a/gitlab/v4/objects/discussions.py +++ b/gitlab/v4/objects/discussions.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, RetrieveMixin, SaveMixin, UpdateMixin from gitlab.types import RequiredOptional @@ -33,11 +31,6 @@ class ProjectCommitDiscussionManager(RetrieveMixin, CreateMixin, RESTManager): _from_parent_attrs = {"project_id": "project_id", "commit_id": "id"} _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectCommitDiscussion: - return cast(ProjectCommitDiscussion, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectIssueDiscussion(RESTObject): notes: ProjectIssueDiscussionNoteManager @@ -49,11 +42,6 @@ class ProjectIssueDiscussionManager(RetrieveMixin, CreateMixin, RESTManager): _from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"} _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueDiscussion: - return cast(ProjectIssueDiscussion, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectMergeRequestDiscussion(SaveMixin, RESTObject): notes: ProjectMergeRequestDiscussionNoteManager @@ -70,13 +58,6 @@ class ProjectMergeRequestDiscussionManager( ) _update_attrs = RequiredOptional(required=("resolved",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestDiscussion: - return cast( - ProjectMergeRequestDiscussion, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectSnippetDiscussion(RESTObject): notes: ProjectSnippetDiscussionNoteManager @@ -87,8 +68,3 @@ class ProjectSnippetDiscussionManager(RetrieveMixin, CreateMixin, RESTManager): _obj_cls = ProjectSnippetDiscussion _from_parent_attrs = {"project_id": "project_id", "snippet_id": "id"} _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectSnippetDiscussion: - return cast(ProjectSnippetDiscussion, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/draft_notes.py b/gitlab/v4/objects/draft_notes.py index 8d7f68902..19ea92cd7 100644 --- a/gitlab/v4/objects/draft_notes.py +++ b/gitlab/v4/objects/draft_notes.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Union +from typing import Any from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin @@ -31,13 +31,6 @@ class ProjectMergeRequestDraftNoteManager(CRUDMixin, RESTManager): ) _update_attrs = RequiredOptional(optional=("position",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestDraftNote: - return cast( - ProjectMergeRequestDraftNote, super().get(id=id, lazy=lazy, **kwargs) - ) - def bulk_publish(self, **kwargs: Any) -> None: path = f"{self.path}/bulk_publish" self.gitlab.http_post(path, **kwargs) diff --git a/gitlab/v4/objects/environments.py b/gitlab/v4/objects/environments.py index d9322fe24..545f2fc7e 100644 --- a/gitlab/v4/objects/environments.py +++ b/gitlab/v4/objects/environments.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, Union +from typing import Any, Dict, Union import requests @@ -53,11 +53,6 @@ class ProjectEnvironmentManager( _update_attrs = RequiredOptional(optional=("name", "external_url")) _list_filters = ("name", "search", "states") - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectEnvironment: - return cast(ProjectEnvironment, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectProtectedEnvironment(ObjectDeleteMixin, RESTObject): _id_attr = "name" @@ -78,10 +73,3 @@ class ProjectProtectedEnvironmentManager( optional=("required_approval_count", "approval_rules"), ) _types = {"deploy_access_levels": ArrayAttribute, "approval_rules": ArrayAttribute} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectProtectedEnvironment: - return cast( - ProjectProtectedEnvironment, super().get(id=id, lazy=lazy, **kwargs) - ) diff --git a/gitlab/v4/objects/epics.py b/gitlab/v4/objects/epics.py index f10ea19a4..8144e7b70 100644 --- a/gitlab/v4/objects/epics.py +++ b/gitlab/v4/objects/epics.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, Optional, TYPE_CHECKING from gitlab import exceptions as exc from gitlab import types @@ -47,9 +47,6 @@ class GroupEpicManager(CRUDMixin, RESTManager): ) _types = {"labels": types.CommaSeparatedListAttribute} - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupEpic: - return cast(GroupEpic, super().get(id=id, lazy=lazy, **kwargs)) - class GroupEpicIssue(ObjectDeleteMixin, SaveMixin, RESTObject): _id_attr = "epic_issue_id" diff --git a/gitlab/v4/objects/events.py b/gitlab/v4/objects/events.py index 9e6b62f0e..ab94ec6bf 100644 --- a/gitlab/v4/objects/events.py +++ b/gitlab/v4/objects/events.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ListMixin, RetrieveMixin @@ -51,13 +49,6 @@ class GroupEpicResourceLabelEventManager(RetrieveMixin, RESTManager): _obj_cls = GroupEpicResourceLabelEvent _from_parent_attrs = {"group_id": "group_id", "epic_id": "id"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupEpicResourceLabelEvent: - return cast( - GroupEpicResourceLabelEvent, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectEvent(Event): pass @@ -78,13 +69,6 @@ class ProjectIssueResourceLabelEventManager(RetrieveMixin, RESTManager): _obj_cls = ProjectIssueResourceLabelEvent _from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueResourceLabelEvent: - return cast( - ProjectIssueResourceLabelEvent, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectIssueResourceMilestoneEvent(RESTObject): pass @@ -95,13 +79,6 @@ class ProjectIssueResourceMilestoneEventManager(RetrieveMixin, RESTManager): _obj_cls = ProjectIssueResourceMilestoneEvent _from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueResourceMilestoneEvent: - return cast( - ProjectIssueResourceMilestoneEvent, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectIssueResourceStateEvent(RESTObject): pass @@ -112,13 +89,6 @@ class ProjectIssueResourceStateEventManager(RetrieveMixin, RESTManager): _obj_cls = ProjectIssueResourceStateEvent _from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueResourceStateEvent: - return cast( - ProjectIssueResourceStateEvent, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectIssueResourceIterationEvent(RESTObject): pass @@ -129,13 +99,6 @@ class ProjectIssueResourceIterationEventManager(RetrieveMixin, RESTManager): _obj_cls = ProjectIssueResourceIterationEvent _from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueResourceIterationEvent: - return cast( - ProjectIssueResourceIterationEvent, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectIssueResourceWeightEvent(RESTObject): pass @@ -146,13 +109,6 @@ class ProjectIssueResourceWeightEventManager(RetrieveMixin, RESTManager): _obj_cls = ProjectIssueResourceWeightEvent _from_parent_attrs = {"project_id": "project_id", "issue_iid": "iid"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueResourceWeightEvent: - return cast( - ProjectIssueResourceWeightEvent, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectMergeRequestResourceLabelEvent(RESTObject): pass @@ -163,14 +119,6 @@ class ProjectMergeRequestResourceLabelEventManager(RetrieveMixin, RESTManager): _obj_cls = ProjectMergeRequestResourceLabelEvent _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestResourceLabelEvent: - return cast( - ProjectMergeRequestResourceLabelEvent, - super().get(id=id, lazy=lazy, **kwargs), - ) - class ProjectMergeRequestResourceMilestoneEvent(RESTObject): pass @@ -181,14 +129,6 @@ class ProjectMergeRequestResourceMilestoneEventManager(RetrieveMixin, RESTManage _obj_cls = ProjectMergeRequestResourceMilestoneEvent _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestResourceMilestoneEvent: - return cast( - ProjectMergeRequestResourceMilestoneEvent, - super().get(id=id, lazy=lazy, **kwargs), - ) - class ProjectMergeRequestResourceStateEvent(RESTObject): pass @@ -199,14 +139,6 @@ class ProjectMergeRequestResourceStateEventManager(RetrieveMixin, RESTManager): _obj_cls = ProjectMergeRequestResourceStateEvent _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestResourceStateEvent: - return cast( - ProjectMergeRequestResourceStateEvent, - super().get(id=id, lazy=lazy, **kwargs), - ) - class UserEvent(Event): pass diff --git a/gitlab/v4/objects/export_import.py b/gitlab/v4/objects/export_import.py index 5e07661b6..a3768ed0f 100644 --- a/gitlab/v4/objects/export_import.py +++ b/gitlab/v4/objects/export_import.py @@ -1,5 +1,3 @@ -from typing import Any, cast - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, DownloadMixin, GetWithoutIdMixin, RefreshMixin from gitlab.types import RequiredOptional @@ -25,9 +23,6 @@ class GroupExportManager(GetWithoutIdMixin, CreateMixin, RESTManager): _obj_cls = GroupExport _from_parent_attrs = {"group_id": "id"} - def get(self, **kwargs: Any) -> GroupExport: - return cast(GroupExport, super().get(**kwargs)) - class GroupImport(RESTObject): _id_attr = None @@ -38,9 +33,6 @@ class GroupImportManager(GetWithoutIdMixin, RESTManager): _obj_cls = GroupImport _from_parent_attrs = {"group_id": "id"} - def get(self, **kwargs: Any) -> GroupImport: - return cast(GroupImport, super().get(**kwargs)) - class ProjectExport(DownloadMixin, RefreshMixin, RESTObject): _id_attr = None @@ -52,9 +44,6 @@ class ProjectExportManager(GetWithoutIdMixin, CreateMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(optional=("description",)) - def get(self, **kwargs: Any) -> ProjectExport: - return cast(ProjectExport, super().get(**kwargs)) - class ProjectImport(RefreshMixin, RESTObject): _id_attr = None @@ -64,6 +53,3 @@ class ProjectImportManager(GetWithoutIdMixin, RESTManager): _path = "/projects/{project_id}/import" _obj_cls = ProjectImport _from_parent_attrs = {"project_id": "id"} - - def get(self, **kwargs: Any) -> ProjectImport: - return cast(ProjectImport, super().get(**kwargs)) diff --git a/gitlab/v4/objects/geo_nodes.py b/gitlab/v4/objects/geo_nodes.py index 771027e6a..2745151db 100644 --- a/gitlab/v4/objects/geo_nodes.py +++ b/gitlab/v4/objects/geo_nodes.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, List, TYPE_CHECKING, Union +from typing import Any, Dict, List, TYPE_CHECKING from gitlab import cli from gitlab import exceptions as exc @@ -66,9 +66,6 @@ class GeoNodeManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager): optional=("enabled", "url", "files_max_capacity", "repos_max_capacity"), ) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GeoNode: - return cast(GeoNode, super().get(id=id, lazy=lazy, **kwargs)) - @cli.register_custom_action(cls_names="GeoNodeManager") @exc.on_http_error(exc.GitlabGetError) def status(self, **kwargs: Any) -> List[Dict[str, Any]]: diff --git a/gitlab/v4/objects/group_access_tokens.py b/gitlab/v4/objects/group_access_tokens.py index fd9bfbabf..0b2251b80 100644 --- a/gitlab/v4/objects/group_access_tokens.py +++ b/gitlab/v4/objects/group_access_tokens.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, @@ -31,8 +29,3 @@ class GroupAccessTokenManager( required=("name", "scopes"), optional=("access_level", "expires_at") ) _types = {"scopes": ArrayAttribute} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupAccessToken: - return cast(GroupAccessToken, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/groups.py b/gitlab/v4/objects/groups.py index 744f2aab4..f9aeb0b19 100644 --- a/gitlab/v4/objects/groups.py +++ b/gitlab/v4/objects/groups.py @@ -1,4 +1,4 @@ -from typing import Any, BinaryIO, cast, Dict, List, Optional, Type, TYPE_CHECKING, Union +from typing import Any, BinaryIO, Dict, List, Optional, Type, TYPE_CHECKING, Union import requests @@ -319,9 +319,6 @@ class GroupManager(CRUDMixin, RESTManager): ) _types = {"avatar": types.ImageAttribute, "skip_groups": types.ArrayAttribute} - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Group: - return cast(Group, super().get(id=id, lazy=lazy, **kwargs)) - @exc.on_http_error(exc.GitlabImportError) def import_group( self, @@ -445,8 +442,3 @@ class GroupSAMLGroupLinkManager(NoUpdateMixin, RESTManager): _obj_cls: Type[GroupSAMLGroupLink] = GroupSAMLGroupLink _from_parent_attrs = {"group_id": "id"} _create_attrs = RequiredOptional(required=("saml_group_name", "access_level")) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupSAMLGroupLink: - return cast(GroupSAMLGroupLink, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/hooks.py b/gitlab/v4/objects/hooks.py index 798f92e4d..087d5759a 100644 --- a/gitlab/v4/objects/hooks.py +++ b/gitlab/v4/objects/hooks.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab import exceptions as exc from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, NoUpdateMixin, ObjectDeleteMixin, SaveMixin @@ -25,9 +23,6 @@ class HookManager(NoUpdateMixin, RESTManager): _obj_cls = Hook _create_attrs = RequiredOptional(required=("url",)) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Hook: - return cast(Hook, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectHook(SaveMixin, ObjectDeleteMixin, RESTObject): _repr_attr = "url" @@ -84,11 +79,6 @@ class ProjectHookManager(CRUDMixin, RESTManager): ), ) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectHook: - return cast(ProjectHook, super().get(id=id, lazy=lazy, **kwargs)) - class GroupHook(SaveMixin, ObjectDeleteMixin, RESTObject): _repr_attr = "url" @@ -152,6 +142,3 @@ class GroupHookManager(CRUDMixin, RESTManager): "token", ), ) - - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupHook: - return cast(GroupHook, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/integrations.py b/gitlab/v4/objects/integrations.py index 4764fee52..4f25ad7e6 100644 --- a/gitlab/v4/objects/integrations.py +++ b/gitlab/v4/objects/integrations.py @@ -3,7 +3,7 @@ https://docs.gitlab.com/ee/api/integrations.html """ -from typing import Any, cast, List, Union +from typing import List from gitlab import cli from gitlab.base import RESTManager, RESTObject @@ -265,11 +265,6 @@ class ProjectIntegrationManager( "youtrack": (("issues_url", "project_url"), ("description", "push_events")), } - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIntegration: - return cast(ProjectIntegration, super().get(id=id, lazy=lazy, **kwargs)) - @cli.register_custom_action( cls_names=("ProjectIntegrationManager", "ProjectServiceManager") ) @@ -288,8 +283,3 @@ class ProjectService(ProjectIntegration): class ProjectServiceManager(ProjectIntegrationManager): _obj_cls = ProjectService - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectService: - return cast(ProjectService, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/invitations.py b/gitlab/v4/objects/invitations.py index 43fbb2d27..516f4aaf8 100644 --- a/gitlab/v4/objects/invitations.py +++ b/gitlab/v4/objects/invitations.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Union +from typing import Any from gitlab.base import RESTManager, RESTObject from gitlab.exceptions import GitlabInvitationError @@ -51,11 +51,6 @@ class ProjectInvitationManager(InvitationMixin, RESTManager): "tasks_to_be_done": ArrayAttribute, } - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectInvitation: - return cast(ProjectInvitation, super().get(id=id, lazy=lazy, **kwargs)) - class GroupInvitation(SaveMixin, ObjectDeleteMixin, RESTObject): _id_attr = "email" @@ -84,8 +79,3 @@ class GroupInvitationManager(InvitationMixin, RESTManager): "user_id": CommaSeparatedListAttribute, "tasks_to_be_done": ArrayAttribute, } - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupInvitation: - return cast(GroupInvitation, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/issues.py b/gitlab/v4/objects/issues.py index df6cf7a5a..bcb5d412a 100644 --- a/gitlab/v4/objects/issues.py +++ b/gitlab/v4/objects/issues.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, List, Optional, Tuple, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING, Union import requests @@ -73,9 +73,6 @@ class IssueManager(RetrieveMixin, RESTManager): ) _types = {"iids": types.ArrayAttribute, "labels": types.CommaSeparatedListAttribute} - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Issue: - return cast(Issue, super().get(id=id, lazy=lazy, **kwargs)) - class GroupIssue(RESTObject): pass @@ -283,11 +280,6 @@ class ProjectIssueManager(CRUDMixin, RESTManager): ) _types = {"iids": types.ArrayAttribute, "labels": types.CommaSeparatedListAttribute} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssue: - return cast(ProjectIssue, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectIssueLink(ObjectDeleteMixin, RESTObject): _id_attr = "issue_link_id" diff --git a/gitlab/v4/objects/job_token_scope.py b/gitlab/v4/objects/job_token_scope.py index ed04a3146..64b579961 100644 --- a/gitlab/v4/objects/job_token_scope.py +++ b/gitlab/v4/objects/job_token_scope.py @@ -1,4 +1,4 @@ -from typing import Any, cast +from typing import cast from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( @@ -33,9 +33,6 @@ class ProjectJobTokenScopeManager(GetWithoutIdMixin, UpdateMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _update_method = UpdateMethod.PATCH - def get(self, **kwargs: Any) -> ProjectJobTokenScope: - return cast(ProjectJobTokenScope, super().get(**kwargs)) - class AllowlistProject(ObjectDeleteMixin, RESTObject): _id_attr = "target_project_id" # note: only true for create endpoint diff --git a/gitlab/v4/objects/jobs.py b/gitlab/v4/objects/jobs.py index b98255acc..8f120035f 100644 --- a/gitlab/v4/objects/jobs.py +++ b/gitlab/v4/objects/jobs.py @@ -1,7 +1,6 @@ from typing import ( Any, Callable, - cast, Dict, Iterator, Literal, @@ -360,6 +359,3 @@ class ProjectJobManager(RetrieveMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _list_filters = ("scope",) _types = {"scope": ArrayAttribute} - - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> ProjectJob: - return cast(ProjectJob, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/labels.py b/gitlab/v4/objects/labels.py index b23062ec9..dac1b1c75 100644 --- a/gitlab/v4/objects/labels.py +++ b/gitlab/v4/objects/labels.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, Optional, Union +from typing import Any, Dict, Optional from gitlab import exceptions as exc from gitlab.base import RESTManager, RESTObject @@ -60,9 +60,6 @@ class GroupLabelManager( required=("name",), optional=("new_name", "color", "description", "priority") ) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupLabel: - return cast(GroupLabel, super().get(id=id, lazy=lazy, **kwargs)) - # Update without ID. # NOTE(jlvillal): Signature doesn't match UpdateMixin.update() so ignore # type error @@ -124,11 +121,6 @@ class ProjectLabelManager( required=("name",), optional=("new_name", "color", "description", "priority") ) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectLabel: - return cast(ProjectLabel, super().get(id=id, lazy=lazy, **kwargs)) - # Update without ID. # NOTE(jlvillal): Signature doesn't match UpdateMixin.update() so ignore # type error diff --git a/gitlab/v4/objects/members.py b/gitlab/v4/objects/members.py index 02523754b..19fa674ae 100644 --- a/gitlab/v4/objects/members.py +++ b/gitlab/v4/objects/members.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab import types from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( @@ -49,11 +47,6 @@ class GroupMemberManager(CRUDMixin, RESTManager): "tasks_to_be_done": types.ArrayAttribute, } - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupMember: - return cast(GroupMember, super().get(id=id, lazy=lazy, **kwargs)) - class GroupBillableMember(ObjectDeleteMixin, RESTObject): _repr_attr = "username" @@ -87,11 +80,6 @@ class GroupMemberAllManager(RetrieveMixin, RESTManager): _obj_cls = GroupMemberAll _from_parent_attrs = {"group_id": "id"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupMemberAll: - return cast(GroupMemberAll, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectMember(SaveMixin, ObjectDeleteMixin, RESTObject): _repr_attr = "username" @@ -114,11 +102,6 @@ class ProjectMemberManager(CRUDMixin, RESTManager): "tasks_to_be_dones": types.ArrayAttribute, } - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMember: - return cast(ProjectMember, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectMemberAll(RESTObject): _repr_attr = "username" @@ -128,8 +111,3 @@ class ProjectMemberAllManager(RetrieveMixin, RESTManager): _path = "/projects/{project_id}/members/all" _obj_cls = ProjectMemberAll _from_parent_attrs = {"project_id": "id"} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMemberAll: - return cast(ProjectMemberAll, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/merge_request_approvals.py b/gitlab/v4/objects/merge_request_approvals.py index 6f8481197..2ec230c42 100644 --- a/gitlab/v4/objects/merge_request_approvals.py +++ b/gitlab/v4/objects/merge_request_approvals.py @@ -1,4 +1,4 @@ -from typing import Any, cast, List, Optional, TYPE_CHECKING, Union +from typing import Any, List, Optional, TYPE_CHECKING from gitlab import exceptions as exc from gitlab.base import RESTManager, RESTObject @@ -45,11 +45,6 @@ class GroupApprovalRuleManager(RetrieveMixin, CreateMixin, UpdateMixin, RESTMana optional=("user_ids", "group_ids", "rule_type"), ) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupApprovalRule: - return cast(GroupApprovalRule, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectApproval(SaveMixin, RESTObject): _id_attr = None @@ -70,9 +65,6 @@ class ProjectApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager): ) _update_method = UpdateMethod.POST - def get(self, **kwargs: Any) -> ProjectApproval: - return cast(ProjectApproval, super().get(**kwargs)) - class ProjectApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject): _id_attr = "id" @@ -90,11 +82,6 @@ class ProjectApprovalRuleManager( optional=("user_ids", "group_ids", "protected_branch_ids", "usernames"), ) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectApprovalRule: - return cast(ProjectApprovalRule, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectMergeRequestApproval(SaveMixin, RESTObject): _id_attr = None @@ -107,9 +94,6 @@ class ProjectMergeRequestApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTMan _update_attrs = RequiredOptional(required=("approvals_required",)) _update_method = UpdateMethod.POST - def get(self, **kwargs: Any) -> ProjectMergeRequestApproval: - return cast(ProjectMergeRequestApproval, super().get(**kwargs)) - @exc.on_http_error(exc.GitlabUpdateError) def set_approvers( self, @@ -188,13 +172,6 @@ class ProjectMergeRequestApprovalRuleManager(CRUDMixin, RESTManager): optional=("approval_project_rule_id", "user_ids", "group_ids", "usernames"), ) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestApprovalRule: - return cast( - ProjectMergeRequestApprovalRule, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectMergeRequestApprovalState(RESTObject): pass @@ -204,6 +181,3 @@ class ProjectMergeRequestApprovalStateManager(GetWithoutIdMixin, RESTManager): _path = "/projects/{project_id}/merge_requests/{mr_iid}/approval_state" _obj_cls = ProjectMergeRequestApprovalState _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"} - - def get(self, **kwargs: Any) -> ProjectMergeRequestApprovalState: - return cast(ProjectMergeRequestApprovalState, super().get(**kwargs)) diff --git a/gitlab/v4/objects/merge_requests.py b/gitlab/v4/objects/merge_requests.py index 30ddc11f5..efc0624e4 100644 --- a/gitlab/v4/objects/merge_requests.py +++ b/gitlab/v4/objects/merge_requests.py @@ -4,7 +4,7 @@ https://docs.gitlab.com/ee/api/merge_request_approvals.html """ -from typing import Any, cast, Dict, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, Optional, TYPE_CHECKING, Union import requests @@ -517,11 +517,6 @@ class ProjectMergeRequestManager(CRUDMixin, RESTManager): "labels": types.CommaSeparatedListAttribute, } - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequest: - return cast(ProjectMergeRequest, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectDeploymentMergeRequest(MergeRequest): pass @@ -541,8 +536,3 @@ class ProjectMergeRequestDiffManager(RetrieveMixin, RESTManager): _path = "/projects/{project_id}/merge_requests/{mr_iid}/versions" _obj_cls = ProjectMergeRequestDiff _from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestDiff: - return cast(ProjectMergeRequestDiff, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/milestones.py b/gitlab/v4/objects/milestones.py index aa0c3a826..602e26c0b 100644 --- a/gitlab/v4/objects/milestones.py +++ b/gitlab/v4/objects/milestones.py @@ -1,4 +1,4 @@ -from typing import Any, cast, TYPE_CHECKING, Union +from typing import Any, TYPE_CHECKING from gitlab import cli from gitlab import exceptions as exc @@ -98,11 +98,6 @@ class GroupMilestoneManager(CRUDMixin, RESTManager): _list_filters = ("iids", "state", "search") _types = {"iids": types.ArrayAttribute} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupMilestone: - return cast(GroupMilestone, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject): _repr_attr = "title" @@ -177,8 +172,3 @@ class ProjectMilestoneManager(CRUDMixin, RESTManager): ) _list_filters = ("iids", "state", "search") _types = {"iids": types.ArrayAttribute} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMilestone: - return cast(ProjectMilestone, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/namespaces.py b/gitlab/v4/objects/namespaces.py index ccaf0eff1..8912c859b 100644 --- a/gitlab/v4/objects/namespaces.py +++ b/gitlab/v4/objects/namespaces.py @@ -1,4 +1,4 @@ -from typing import Any, cast, TYPE_CHECKING, Union +from typing import Any, TYPE_CHECKING from gitlab import cli from gitlab import exceptions as exc @@ -21,9 +21,6 @@ class NamespaceManager(RetrieveMixin, RESTManager): _obj_cls = Namespace _list_filters = ("search",) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Namespace: - return cast(Namespace, super().get(id=id, lazy=lazy, **kwargs)) - @cli.register_custom_action( cls_names="NamespaceManager", required=("namespace", "parent_id") ) diff --git a/gitlab/v4/objects/notes.py b/gitlab/v4/objects/notes.py index a083e55af..2cc1f720a 100644 --- a/gitlab/v4/objects/notes.py +++ b/gitlab/v4/objects/notes.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, @@ -55,11 +53,6 @@ class GroupEpicNoteManager(CRUDMixin, RESTManager): _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupEpicNote: - return cast(GroupEpicNote, super().get(id=id, lazy=lazy, **kwargs)) - class GroupEpicDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -78,11 +71,6 @@ class GroupEpicDiscussionNoteManager( _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupEpicDiscussionNote: - return cast(GroupEpicDiscussionNote, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectNote(RESTObject): pass @@ -94,11 +82,6 @@ class ProjectNoteManager(RetrieveMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("body",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectNote: - return cast(ProjectNote, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectCommitDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -122,13 +105,6 @@ class ProjectCommitDiscussionNoteManager( ) _update_attrs = RequiredOptional(required=("body",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectCommitDiscussionNote: - return cast( - ProjectCommitDiscussionNote, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectIssueNote(SaveMixin, ObjectDeleteMixin, RESTObject): awardemojis: ProjectIssueNoteAwardEmojiManager @@ -141,11 +117,6 @@ class ProjectIssueNoteManager(CRUDMixin, RESTManager): _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueNote: - return cast(ProjectIssueNote, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectIssueDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -166,11 +137,6 @@ class ProjectIssueDiscussionNoteManager( _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueDiscussionNote: - return cast(ProjectIssueDiscussionNote, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectMergeRequestNote(SaveMixin, ObjectDeleteMixin, RESTObject): awardemojis: ProjectMergeRequestNoteAwardEmojiManager @@ -183,11 +149,6 @@ class ProjectMergeRequestNoteManager(CRUDMixin, RESTManager): _create_attrs = RequiredOptional(required=("body",)) _update_attrs = RequiredOptional(required=("body",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestNote: - return cast(ProjectMergeRequestNote, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectMergeRequestDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -209,13 +170,6 @@ class ProjectMergeRequestDiscussionNoteManager( _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestDiscussionNote: - return cast( - ProjectMergeRequestDiscussionNote, super().get(id=id, lazy=lazy, **kwargs) - ) - class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject): awardemojis: ProjectSnippetNoteAwardEmojiManager @@ -228,11 +182,6 @@ class ProjectSnippetNoteManager(CRUDMixin, RESTManager): _create_attrs = RequiredOptional(required=("body",)) _update_attrs = RequiredOptional(required=("body",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectSnippetNote: - return cast(ProjectSnippetNote, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectSnippetDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): pass @@ -253,10 +202,3 @@ class ProjectSnippetDiscussionNoteManager( } _create_attrs = RequiredOptional(required=("body",), optional=("created_at",)) _update_attrs = RequiredOptional(required=("body",)) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectSnippetDiscussionNote: - return cast( - ProjectSnippetDiscussionNote, super().get(id=id, lazy=lazy, **kwargs) - ) diff --git a/gitlab/v4/objects/notification_settings.py b/gitlab/v4/objects/notification_settings.py index 4b38549a3..998a92929 100644 --- a/gitlab/v4/objects/notification_settings.py +++ b/gitlab/v4/objects/notification_settings.py @@ -1,5 +1,3 @@ -from typing import Any, cast - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import GetWithoutIdMixin, SaveMixin, UpdateMixin from gitlab.types import RequiredOptional @@ -39,9 +37,6 @@ class NotificationSettingsManager(GetWithoutIdMixin, UpdateMixin, RESTManager): ), ) - def get(self, **kwargs: Any) -> NotificationSettings: - return cast(NotificationSettings, super().get(**kwargs)) - class GroupNotificationSettings(NotificationSettings): pass @@ -52,9 +47,6 @@ class GroupNotificationSettingsManager(NotificationSettingsManager): _obj_cls = GroupNotificationSettings _from_parent_attrs = {"group_id": "id"} - def get(self, **kwargs: Any) -> GroupNotificationSettings: - return cast(GroupNotificationSettings, super().get(id=id, **kwargs)) - class ProjectNotificationSettings(NotificationSettings): pass @@ -64,6 +56,3 @@ class ProjectNotificationSettingsManager(NotificationSettingsManager): _path = "/projects/{project_id}/notification_settings" _obj_cls = ProjectNotificationSettings _from_parent_attrs = {"project_id": "id"} - - def get(self, **kwargs: Any) -> ProjectNotificationSettings: - return cast(ProjectNotificationSettings, super().get(id=id, **kwargs)) diff --git a/gitlab/v4/objects/packages.py b/gitlab/v4/objects/packages.py index 24c1c6868..05677780f 100644 --- a/gitlab/v4/objects/packages.py +++ b/gitlab/v4/objects/packages.py @@ -9,7 +9,6 @@ Any, BinaryIO, Callable, - cast, Iterator, Literal, Optional, @@ -248,11 +247,6 @@ class ProjectPackageManager(ListMixin, GetMixin, DeleteMixin, RESTManager): "package_name", ) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectPackage: - return cast(ProjectPackage, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectPackageFile(ObjectDeleteMixin, RESTObject): pass diff --git a/gitlab/v4/objects/pages.py b/gitlab/v4/objects/pages.py index ed1e2e11a..6891b2a03 100644 --- a/gitlab/v4/objects/pages.py +++ b/gitlab/v4/objects/pages.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CRUDMixin, @@ -46,11 +44,6 @@ class ProjectPagesDomainManager(CRUDMixin, RESTManager): ) _update_attrs = RequiredOptional(optional=("certificate", "key")) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectPagesDomain: - return cast(ProjectPagesDomain, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectPages(ObjectDeleteMixin, RefreshMixin, RESTObject): _id_attr = None @@ -64,6 +57,3 @@ class ProjectPagesManager(DeleteMixin, UpdateMixin, GetWithoutIdMixin, RESTManag optional=("pages_unique_domain_enabled", "pages_https_only") ) _update_method: UpdateMethod = UpdateMethod.PATCH - - def get(self, **kwargs: Any) -> ProjectPages: - return cast(ProjectPages, super().get(**kwargs)) diff --git a/gitlab/v4/objects/personal_access_tokens.py b/gitlab/v4/objects/personal_access_tokens.py index 37a2302a4..12161a049 100644 --- a/gitlab/v4/objects/personal_access_tokens.py +++ b/gitlab/v4/objects/personal_access_tokens.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, @@ -28,11 +26,6 @@ class PersonalAccessTokenManager(DeleteMixin, RetrieveMixin, RotateMixin, RESTMa _obj_cls = PersonalAccessToken _list_filters = ("user_id",) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> PersonalAccessToken: - return cast(PersonalAccessToken, super().get(id=id, lazy=lazy, **kwargs)) - class UserPersonalAccessToken(RESTObject): pass diff --git a/gitlab/v4/objects/pipelines.py b/gitlab/v4/objects/pipelines.py index 3236e26a3..303629ada 100644 --- a/gitlab/v4/objects/pipelines.py +++ b/gitlab/v4/objects/pipelines.py @@ -109,11 +109,6 @@ class ProjectPipelineManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManage ) _create_attrs = RequiredOptional(required=("ref",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectPipeline: - return cast(ProjectPipeline, super().get(id=id, lazy=lazy, **kwargs)) - def create( self, data: Optional[Dict[str, Any]] = None, **kwargs: Any ) -> ProjectPipeline: @@ -272,11 +267,6 @@ class ProjectPipelineScheduleManager(CRUDMixin, RESTManager): optional=("description", "ref", "cron", "cron_timezone", "active"), ) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectPipelineSchedule: - return cast(ProjectPipelineSchedule, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectPipelineTestReport(RESTObject): _id_attr = None @@ -287,9 +277,6 @@ class ProjectPipelineTestReportManager(GetWithoutIdMixin, RESTManager): _obj_cls = ProjectPipelineTestReport _from_parent_attrs = {"project_id": "project_id", "pipeline_id": "id"} - def get(self, **kwargs: Any) -> ProjectPipelineTestReport: - return cast(ProjectPipelineTestReport, super().get(**kwargs)) - class ProjectPipelineTestReportSummary(RESTObject): _id_attr = None @@ -299,6 +286,3 @@ class ProjectPipelineTestReportSummaryManager(GetWithoutIdMixin, RESTManager): _path = "/projects/{project_id}/pipelines/{pipeline_id}/test_report_summary" _obj_cls = ProjectPipelineTestReportSummary _from_parent_attrs = {"project_id": "project_id", "pipeline_id": "id"} - - def get(self, **kwargs: Any) -> ProjectPipelineTestReportSummary: - return cast(ProjectPipelineTestReportSummary, super().get(**kwargs)) diff --git a/gitlab/v4/objects/project_access_tokens.py b/gitlab/v4/objects/project_access_tokens.py index 3dee4a715..ea01a29da 100644 --- a/gitlab/v4/objects/project_access_tokens.py +++ b/gitlab/v4/objects/project_access_tokens.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, @@ -31,8 +29,3 @@ class ProjectAccessTokenManager( required=("name", "scopes"), optional=("access_level", "expires_at") ) _types = {"scopes": ArrayAttribute} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectAccessToken: - return cast(ProjectAccessToken, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py index 60587fa13..d585eb9d5 100644 --- a/gitlab/v4/objects/projects.py +++ b/gitlab/v4/objects/projects.py @@ -867,9 +867,6 @@ class ProjectManager(CRUDMixin, RESTManager): "topics": types.ArrayAttribute, } - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Project: - return cast(Project, super().get(id=id, lazy=lazy, **kwargs)) - @exc.on_http_error(exc.GitlabImportError) def import_project( self, @@ -1267,9 +1264,6 @@ class ProjectPullMirrorManager(GetWithoutIdMixin, UpdateMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _update_attrs = RequiredOptional(optional=("url",)) - def get(self, **kwargs: Any) -> ProjectPullMirror: - return cast(ProjectPullMirror, super().get(**kwargs)) - @exc.on_http_error(exc.GitlabCreateError) def create(self, data: Dict[str, Any], **kwargs: Any) -> ProjectPullMirror: """Create a new object. @@ -1325,9 +1319,6 @@ class ProjectStorageManager(GetWithoutIdMixin, RESTManager): _obj_cls = ProjectStorage _from_parent_attrs = {"project_id": "id"} - def get(self, **kwargs: Any) -> ProjectStorage: - return cast(ProjectStorage, super().get(**kwargs)) - class SharedProject(RESTObject): pass diff --git a/gitlab/v4/objects/push_rules.py b/gitlab/v4/objects/push_rules.py index 9b4980b16..0b5c5a5b9 100644 --- a/gitlab/v4/objects/push_rules.py +++ b/gitlab/v4/objects/push_rules.py @@ -1,5 +1,3 @@ -from typing import Any, cast - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, @@ -60,9 +58,6 @@ class ProjectPushRulesManager( ), ) - def get(self, **kwargs: Any) -> ProjectPushRules: - return cast(ProjectPushRules, super().get(**kwargs)) - class GroupPushRules(SaveMixin, ObjectDeleteMixin, RESTObject): _id_attr = None @@ -104,6 +99,3 @@ class GroupPushRulesManager( "reject_unsigned_commits", ), ) - - def get(self, **kwargs: Any) -> GroupPushRules: - return cast(GroupPushRules, super().get(**kwargs)) diff --git a/gitlab/v4/objects/releases.py b/gitlab/v4/objects/releases.py index 97b336dfe..9dc9439dd 100644 --- a/gitlab/v4/objects/releases.py +++ b/gitlab/v4/objects/releases.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin from gitlab.types import ArrayAttribute, RequiredOptional @@ -35,11 +33,6 @@ class ProjectReleaseManager(CRUDMixin, RESTManager): ) _types = {"milestones": ArrayAttribute} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectRelease: - return cast(ProjectRelease, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectReleaseLink(ObjectDeleteMixin, SaveMixin, RESTObject): pass @@ -56,8 +49,3 @@ class ProjectReleaseLinkManager(CRUDMixin, RESTManager): _update_attrs = RequiredOptional( optional=("name", "url", "filepath", "direct_asset_path", "link_type") ) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectReleaseLink: - return cast(ProjectReleaseLink, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/resource_groups.py b/gitlab/v4/objects/resource_groups.py index 1ca34f662..ec5cfcf5d 100644 --- a/gitlab/v4/objects/resource_groups.py +++ b/gitlab/v4/objects/resource_groups.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ListMixin, RetrieveMixin, SaveMixin, UpdateMixin from gitlab.types import RequiredOptional @@ -29,11 +27,6 @@ class ProjectResourceGroupManager(RetrieveMixin, UpdateMixin, RESTManager): ) _update_attrs = RequiredOptional(optional=("process_mode",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectResourceGroup: - return cast(ProjectResourceGroup, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectResourceGroupUpcomingJob(RESTObject): pass diff --git a/gitlab/v4/objects/runners.py b/gitlab/v4/objects/runners.py index 3368a1ef7..9d0eb3a83 100644 --- a/gitlab/v4/objects/runners.py +++ b/gitlab/v4/objects/runners.py @@ -1,4 +1,4 @@ -from typing import Any, cast, List, Optional, Union +from typing import Any, List, Optional from gitlab import cli from gitlab import exceptions as exc @@ -120,9 +120,6 @@ def verify(self, token: str, **kwargs: Any) -> None: post_data = {"token": token} self.gitlab.http_post(path, post_data=post_data, **kwargs) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Runner: - return cast(Runner, super().get(id=id, lazy=lazy, **kwargs)) - class RunnerAll(RESTObject): _repr_attr = "description" diff --git a/gitlab/v4/objects/secure_files.py b/gitlab/v4/objects/secure_files.py index 9a71a6302..0cd8454f8 100644 --- a/gitlab/v4/objects/secure_files.py +++ b/gitlab/v4/objects/secure_files.py @@ -6,7 +6,6 @@ from typing import ( Any, Callable, - cast, Iterator, Literal, Optional, @@ -108,8 +107,3 @@ class ProjectSecureFileManager(NoUpdateMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("name", "file")) _types = {"file": FileAttribute} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectSecureFile: - return cast(ProjectSecureFile, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/settings.py b/gitlab/v4/objects/settings.py index cfddf95db..328f91073 100644 --- a/gitlab/v4/objects/settings.py +++ b/gitlab/v4/objects/settings.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, Optional, Union +from typing import Any, Dict, Optional, Union from gitlab import exceptions as exc from gitlab import types @@ -115,6 +115,3 @@ def update( if "domain_whitelist" in data and data["domain_whitelist"] is None: data.pop("domain_whitelist") return super().update(id, data, **kwargs) - - def get(self, **kwargs: Any) -> ApplicationSettings: - return cast(ApplicationSettings, super().get(**kwargs)) diff --git a/gitlab/v4/objects/snippets.py b/gitlab/v4/objects/snippets.py index ebb304a2d..48eef463a 100644 --- a/gitlab/v4/objects/snippets.py +++ b/gitlab/v4/objects/snippets.py @@ -1,7 +1,6 @@ from typing import ( Any, Callable, - cast, Iterator, List, Literal, @@ -199,9 +198,6 @@ def public(self, **kwargs: Any) -> Union[RESTObjectList, List[RESTObject]]: ) return self.list(path="/snippets/public", **kwargs) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Snippet: - return cast(Snippet, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectSnippet(UserAgentDetailMixin, SaveMixin, ObjectDeleteMixin, RESTObject): _url = "/projects/{project_id}/snippets" @@ -308,8 +304,3 @@ class ProjectSnippetManager(CRUDMixin, RESTManager): "description", ), ) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectSnippet: - return cast(ProjectSnippet, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/statistics.py b/gitlab/v4/objects/statistics.py index ce4dc3a25..ce8f96c3b 100644 --- a/gitlab/v4/objects/statistics.py +++ b/gitlab/v4/objects/statistics.py @@ -1,5 +1,3 @@ -from typing import Any, cast - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import GetWithoutIdMixin, RefreshMixin from gitlab.types import ArrayAttribute @@ -27,9 +25,6 @@ class ProjectAdditionalStatisticsManager(GetWithoutIdMixin, RESTManager): _obj_cls = ProjectAdditionalStatistics _from_parent_attrs = {"project_id": "id"} - def get(self, **kwargs: Any) -> ProjectAdditionalStatistics: - return cast(ProjectAdditionalStatistics, super().get(**kwargs)) - class IssuesStatistics(RefreshMixin, RESTObject): _id_attr = None @@ -41,9 +36,6 @@ class IssuesStatisticsManager(GetWithoutIdMixin, RESTManager): _list_filters = ("iids",) _types = {"iids": ArrayAttribute} - def get(self, **kwargs: Any) -> IssuesStatistics: - return cast(IssuesStatistics, super().get(**kwargs)) - class GroupIssuesStatistics(RefreshMixin, RESTObject): _id_attr = None @@ -56,9 +48,6 @@ class GroupIssuesStatisticsManager(GetWithoutIdMixin, RESTManager): _list_filters = ("iids",) _types = {"iids": ArrayAttribute} - def get(self, **kwargs: Any) -> GroupIssuesStatistics: - return cast(GroupIssuesStatistics, super().get(**kwargs)) - class ProjectIssuesStatistics(RefreshMixin, RESTObject): _id_attr = None @@ -71,9 +60,6 @@ class ProjectIssuesStatisticsManager(GetWithoutIdMixin, RESTManager): _list_filters = ("iids",) _types = {"iids": ArrayAttribute} - def get(self, **kwargs: Any) -> ProjectIssuesStatistics: - return cast(ProjectIssuesStatistics, super().get(**kwargs)) - class ApplicationStatistics(RESTObject): _id_attr = None @@ -82,6 +68,3 @@ class ApplicationStatistics(RESTObject): class ApplicationStatisticsManager(GetWithoutIdMixin, RESTManager): _path = "/application/statistics" _obj_cls = ApplicationStatistics - - def get(self, **kwargs: Any) -> ApplicationStatistics: - return cast(ApplicationStatistics, super().get(**kwargs)) diff --git a/gitlab/v4/objects/tags.py b/gitlab/v4/objects/tags.py index 43342649f..dab309b07 100644 --- a/gitlab/v4/objects/tags.py +++ b/gitlab/v4/objects/tags.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin from gitlab.types import RequiredOptional @@ -25,9 +23,6 @@ class ProjectTagManager(NoUpdateMixin, RESTManager): required=("tag_name", "ref"), optional=("message",) ) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> ProjectTag: - return cast(ProjectTag, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectProtectedTag(ObjectDeleteMixin, RESTObject): _id_attr = "name" @@ -41,8 +36,3 @@ class ProjectProtectedTagManager(NoUpdateMixin, RESTManager): _create_attrs = RequiredOptional( required=("name",), optional=("create_access_level",) ) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectProtectedTag: - return cast(ProjectProtectedTag, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/templates.py b/gitlab/v4/objects/templates.py index 343ac4ca7..9ff5cc71e 100644 --- a/gitlab/v4/objects/templates.py +++ b/gitlab/v4/objects/templates.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import RetrieveMixin @@ -35,9 +33,6 @@ class DockerfileManager(RetrieveMixin, RESTManager): _path = "/templates/dockerfiles" _obj_cls = Dockerfile - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Dockerfile: - return cast(Dockerfile, super().get(id=id, lazy=lazy, **kwargs)) - class Gitignore(RESTObject): _id_attr = "name" @@ -47,9 +42,6 @@ class GitignoreManager(RetrieveMixin, RESTManager): _path = "/templates/gitignores" _obj_cls = Gitignore - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Gitignore: - return cast(Gitignore, super().get(id=id, lazy=lazy, **kwargs)) - class Gitlabciyml(RESTObject): _id_attr = "name" @@ -59,11 +51,6 @@ class GitlabciymlManager(RetrieveMixin, RESTManager): _path = "/templates/gitlab_ci_ymls" _obj_cls = Gitlabciyml - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> Gitlabciyml: - return cast(Gitlabciyml, super().get(id=id, lazy=lazy, **kwargs)) - class License(RESTObject): _id_attr = "key" @@ -75,9 +62,6 @@ class LicenseManager(RetrieveMixin, RESTManager): _list_filters = ("popular",) _optional_get_attrs = ("project", "fullname") - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> License: - return cast(License, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectDockerfileTemplate(RESTObject): _id_attr = "name" @@ -88,11 +72,6 @@ class ProjectDockerfileTemplateManager(RetrieveMixin, RESTManager): _obj_cls = ProjectDockerfileTemplate _from_parent_attrs = {"project_id": "id"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectDockerfileTemplate: - return cast(ProjectDockerfileTemplate, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectGitignoreTemplate(RESTObject): _id_attr = "name" @@ -103,11 +82,6 @@ class ProjectGitignoreTemplateManager(RetrieveMixin, RESTManager): _obj_cls = ProjectGitignoreTemplate _from_parent_attrs = {"project_id": "id"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectGitignoreTemplate: - return cast(ProjectGitignoreTemplate, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectGitlabciymlTemplate(RESTObject): _id_attr = "name" @@ -118,11 +92,6 @@ class ProjectGitlabciymlTemplateManager(RetrieveMixin, RESTManager): _obj_cls = ProjectGitlabciymlTemplate _from_parent_attrs = {"project_id": "id"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectGitlabciymlTemplate: - return cast(ProjectGitlabciymlTemplate, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectLicenseTemplate(RESTObject): _id_attr = "key" @@ -133,11 +102,6 @@ class ProjectLicenseTemplateManager(RetrieveMixin, RESTManager): _obj_cls = ProjectLicenseTemplate _from_parent_attrs = {"project_id": "id"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectLicenseTemplate: - return cast(ProjectLicenseTemplate, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectIssueTemplate(RESTObject): _id_attr = "name" @@ -148,11 +112,6 @@ class ProjectIssueTemplateManager(RetrieveMixin, RESTManager): _obj_cls = ProjectIssueTemplate _from_parent_attrs = {"project_id": "id"} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectIssueTemplate: - return cast(ProjectIssueTemplate, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectMergeRequestTemplate(RESTObject): _id_attr = "name" @@ -162,10 +121,3 @@ class ProjectMergeRequestTemplateManager(RetrieveMixin, RESTManager): _path = "/projects/{project_id}/templates/merge_requests" _obj_cls = ProjectMergeRequestTemplate _from_parent_attrs = {"project_id": "id"} - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectMergeRequestTemplate: - return cast( - ProjectMergeRequestTemplate, super().get(id=id, lazy=lazy, **kwargs) - ) diff --git a/gitlab/v4/objects/topics.py b/gitlab/v4/objects/topics.py index 0dd4285ce..9aaa124c0 100644 --- a/gitlab/v4/objects/topics.py +++ b/gitlab/v4/objects/topics.py @@ -1,4 +1,4 @@ -from typing import Any, cast, Dict, TYPE_CHECKING, Union +from typing import Any, Dict, TYPE_CHECKING, Union from gitlab import cli from gitlab import exceptions as exc @@ -29,9 +29,6 @@ class TopicManager(CRUDMixin, RESTManager): _update_attrs = RequiredOptional(optional=("avatar", "description", "name")) _types = {"avatar": types.ImageAttribute} - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Topic: - return cast(Topic, super().get(id=id, lazy=lazy, **kwargs)) - @cli.register_custom_action( cls_names="TopicManager", required=("source_topic_id", "target_topic_id"), diff --git a/gitlab/v4/objects/triggers.py b/gitlab/v4/objects/triggers.py index 8c0d88536..609138047 100644 --- a/gitlab/v4/objects/triggers.py +++ b/gitlab/v4/objects/triggers.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin from gitlab.types import RequiredOptional @@ -20,8 +18,3 @@ class ProjectTriggerManager(CRUDMixin, RESTManager): _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional(required=("description",)) _update_attrs = RequiredOptional(required=("description",)) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectTrigger: - return cast(ProjectTrigger, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py index b7a3159b9..1a0f84e88 100644 --- a/gitlab/v4/objects/users.py +++ b/gitlab/v4/objects/users.py @@ -78,11 +78,6 @@ class CurrentUserEmailManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManag _obj_cls = CurrentUserEmail _create_attrs = RequiredOptional(required=("email",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> CurrentUserEmail: - return cast(CurrentUserEmail, super().get(id=id, lazy=lazy, **kwargs)) - class CurrentUserGPGKey(ObjectDeleteMixin, RESTObject): pass @@ -93,11 +88,6 @@ class CurrentUserGPGKeyManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTMana _obj_cls = CurrentUserGPGKey _create_attrs = RequiredOptional(required=("key",)) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> CurrentUserGPGKey: - return cast(CurrentUserGPGKey, super().get(id=id, lazy=lazy, **kwargs)) - class CurrentUserKey(ObjectDeleteMixin, RESTObject): _repr_attr = "title" @@ -108,11 +98,6 @@ class CurrentUserKeyManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManager _obj_cls = CurrentUserKey _create_attrs = RequiredOptional(required=("title", "key")) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> CurrentUserKey: - return cast(CurrentUserKey, super().get(id=id, lazy=lazy, **kwargs)) - class CurrentUserRunner(RESTObject): pass @@ -149,9 +134,6 @@ class CurrentUserStatusManager(GetWithoutIdMixin, UpdateMixin, RESTManager): _obj_cls = CurrentUserStatus _update_attrs = RequiredOptional(optional=("emoji", "message")) - def get(self, **kwargs: Any) -> CurrentUserStatus: - return cast(CurrentUserStatus, super().get(**kwargs)) - class CurrentUser(RESTObject): _id_attr = None @@ -168,9 +150,6 @@ class CurrentUserManager(GetWithoutIdMixin, RESTManager): _path = "/user" _obj_cls = CurrentUser - def get(self, **kwargs: Any) -> CurrentUser: - return cast(CurrentUser, super().get(**kwargs)) - class User(SaveMixin, ObjectDeleteMixin, RESTObject): _repr_attr = "username" @@ -468,9 +447,6 @@ class UserManager(CRUDMixin, RESTManager): ) _types = {"confirm": types.LowercaseStringAttribute, "avatar": types.ImageAttribute} - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> User: - return cast(User, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectUser(RESTObject): pass @@ -494,9 +470,6 @@ class UserEmailManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManager): _from_parent_attrs = {"user_id": "id"} _create_attrs = RequiredOptional(required=("email",)) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> UserEmail: - return cast(UserEmail, super().get(id=id, lazy=lazy, **kwargs)) - class UserActivities(RESTObject): _id_attr = "username" @@ -512,9 +485,6 @@ class UserStatusManager(GetWithoutIdMixin, RESTManager): _obj_cls = UserStatus _from_parent_attrs = {"user_id": "id"} - def get(self, **kwargs: Any) -> UserStatus: - return cast(UserStatus, super().get(**kwargs)) - class UserActivitiesManager(ListMixin, RESTManager): _path = "/user/activities" @@ -531,9 +501,6 @@ class UserGPGKeyManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManager): _from_parent_attrs = {"user_id": "id"} _create_attrs = RequiredOptional(required=("key",)) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> UserGPGKey: - return cast(UserGPGKey, super().get(id=id, lazy=lazy, **kwargs)) - class UserKey(ObjectDeleteMixin, RESTObject): pass @@ -545,9 +512,6 @@ class UserKeyManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManager): _from_parent_attrs = {"user_id": "id"} _create_attrs = RequiredOptional(required=("title", "key")) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> UserKey: - return cast(UserKey, super().get(id=id, lazy=lazy, **kwargs)) - class UserIdentityProviderManager(DeleteMixin, RESTManager): """Manager for user identities. @@ -574,11 +538,6 @@ class UserImpersonationTokenManager(NoUpdateMixin, RESTManager): _list_filters = ("state",) _types = {"scopes": ArrayAttribute} - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> UserImpersonationToken: - return cast(UserImpersonationToken, super().get(id=id, lazy=lazy, **kwargs)) - class UserMembership(RESTObject): _id_attr = "source_id" @@ -590,11 +549,6 @@ class UserMembershipManager(RetrieveMixin, RESTManager): _from_parent_attrs = {"user_id": "id"} _list_filters = ("type",) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> UserMembership: - return cast(UserMembership, super().get(id=id, lazy=lazy, **kwargs)) - # Having this outside projects avoids circular imports due to ProjectUser class UserProject(RESTObject): diff --git a/gitlab/v4/objects/variables.py b/gitlab/v4/objects/variables.py index 4cfbeb460..b5567763c 100644 --- a/gitlab/v4/objects/variables.py +++ b/gitlab/v4/objects/variables.py @@ -5,8 +5,6 @@ https://docs.gitlab.com/ee/api/group_level_variables.html """ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin from gitlab.types import RequiredOptional @@ -35,9 +33,6 @@ class VariableManager(CRUDMixin, RESTManager): required=("key", "value"), optional=("protected", "variable_type", "masked") ) - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Variable: - return cast(Variable, super().get(id=id, lazy=lazy, **kwargs)) - class GroupVariable(SaveMixin, ObjectDeleteMixin, RESTObject): _id_attr = "key" @@ -54,11 +49,6 @@ class GroupVariableManager(CRUDMixin, RESTManager): required=("key", "value"), optional=("protected", "variable_type", "masked") ) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> GroupVariable: - return cast(GroupVariable, super().get(id=id, lazy=lazy, **kwargs)) - class ProjectVariable(SaveMixin, ObjectDeleteMixin, RESTObject): _id_attr = "key" @@ -76,8 +66,3 @@ class ProjectVariableManager(CRUDMixin, RESTManager): required=("key", "value"), optional=("protected", "variable_type", "masked", "environment_scope"), ) - - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectVariable: - return cast(ProjectVariable, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/gitlab/v4/objects/wikis.py b/gitlab/v4/objects/wikis.py index 40f661e51..3be21aefb 100644 --- a/gitlab/v4/objects/wikis.py +++ b/gitlab/v4/objects/wikis.py @@ -1,5 +1,3 @@ -from typing import Any, cast, Union - from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin, UploadMixin from gitlab.types import RequiredOptional @@ -28,11 +26,6 @@ class ProjectWikiManager(CRUDMixin, RESTManager): _update_attrs = RequiredOptional(optional=("title", "content", "format")) _list_filters = ("with_content",) - def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any - ) -> ProjectWiki: - return cast(ProjectWiki, super().get(id=id, lazy=lazy, **kwargs)) - class GroupWiki(SaveMixin, ObjectDeleteMixin, UploadMixin, RESTObject): _id_attr = "slug" @@ -49,6 +42,3 @@ class GroupWikiManager(CRUDMixin, RESTManager): ) _update_attrs = RequiredOptional(optional=("title", "content", "format")) _list_filters = ("with_content",) - - def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupWiki: - return cast(GroupWiki, super().get(id=id, lazy=lazy, **kwargs)) diff --git a/tests/functional/api/test_merge_requests.py b/tests/functional/api/test_merge_requests.py index cfa7fde80..961605c83 100644 --- a/tests/functional/api/test_merge_requests.py +++ b/tests/functional/api/test_merge_requests.py @@ -180,7 +180,7 @@ def test_merge_request_reset_approvals(gitlab_url, project): # Pause to let GL catch up (happens on hosted too, sometimes takes a while for server to be ready to merge) time.sleep(5) - mr = bot_project.mergerequests.list()[0] # type: ignore[index] + mr = bot_project.mergerequests.list()[0] assert mr.reset_approvals() diff --git a/tests/unit/meta/test_ensure_type_hints.py b/tests/unit/meta/test_ensure_type_hints.py deleted file mode 100644 index 0a29db03e..000000000 --- a/tests/unit/meta/test_ensure_type_hints.py +++ /dev/null @@ -1,136 +0,0 @@ -""" -Ensure type-hints are setup correctly and detect if missing functions. - -Original notes by John L. Villalovos - -""" - -import dataclasses -import functools -import inspect -from typing import Optional, Type - -import pytest - -import gitlab.mixins -import gitlab.v4.objects - - -@functools.total_ordering -@dataclasses.dataclass(frozen=True) -class ClassInfo: - name: str - type: Type # type: ignore[type-arg] - - def __lt__(self, other: object) -> bool: - if not isinstance(other, ClassInfo): - return NotImplemented - return (self.type.__module__, self.name) < (other.type.__module__, other.name) - - def __eq__(self, other: object) -> bool: - if not isinstance(other, ClassInfo): - return NotImplemented - return (self.type.__module__, self.name) == (other.type.__module__, other.name) - - -def pytest_generate_tests(metafunc: pytest.Metafunc) -> None: - """Find all of the classes in gitlab.v4.objects and pass them to our test - function""" - - class_info_set = set() - for _, module_value in inspect.getmembers(gitlab.v4.objects): - if not inspect.ismodule(module_value): - # We only care about the modules - continue - # Iterate through all the classes in our module - for class_name, class_value in inspect.getmembers(module_value): - if not inspect.isclass(class_value): - continue - - module_name = class_value.__module__ - # Ignore imported classes from gitlab.base - if module_name == "gitlab.base": - continue - - if not class_name.endswith("Manager"): - continue - - class_info_set.add(ClassInfo(name=class_name, type=class_value)) - - metafunc.parametrize("class_info", sorted(class_info_set)) - - -GET_ID_METHOD_TEMPLATE = """ -def get( - self, id: Union[str, int], lazy: bool = False, **kwargs: Any -) -> {obj_cls.__name__}: - return cast({obj_cls.__name__}, super().get(id=id, lazy=lazy, **kwargs)) - -You may also need to add the following imports: -from typing import Any, cast, Union" -""" - -GET_WITHOUT_ID_METHOD_TEMPLATE = """ -def get(self, **kwargs: Any) -> {obj_cls.__name__}: - return cast({obj_cls.__name__}, super().get(**kwargs)) - -You may also need to add the following imports: -from typing import Any, cast" -""" - - -class TestTypeHints: - def test_check_get_function_type_hints(self, class_info: ClassInfo) -> None: - """Ensure classes derived from GetMixin have defined a 'get()' method with - correct type-hints. - """ - self.get_check_helper( - base_type=gitlab.mixins.GetMixin, - class_info=class_info, - method_template=GET_ID_METHOD_TEMPLATE, - optional_return=False, - ) - - def test_check_get_without_id_function_type_hints( - self, class_info: ClassInfo - ) -> None: - """Ensure classes derived from GetMixin have defined a 'get()' method with - correct type-hints. - """ - self.get_check_helper( - base_type=gitlab.mixins.GetWithoutIdMixin, - class_info=class_info, - method_template=GET_WITHOUT_ID_METHOD_TEMPLATE, - optional_return=False, - ) - - def get_check_helper( - self, - *, - base_type: Type, # type: ignore[type-arg] - class_info: ClassInfo, - method_template: str, - optional_return: bool, - ) -> None: - if not class_info.name.endswith("Manager"): - return - mro = class_info.type.mro() - # The class needs to be derived from GetMixin or we ignore it - if base_type not in mro: - return - - obj_cls = class_info.type._obj_cls - signature = inspect.signature(class_info.type.get) - filename = inspect.getfile(class_info.type) - - fail_message = ( - f"class definition for {class_info.name!r} in file {filename!r} " - f"must have defined a 'get' method with a return annotation of " - f"{obj_cls} but found {signature.return_annotation}\n" - f"Recommend adding the following method:\n" - ) - fail_message += method_template.format(obj_cls=obj_cls) - check_type = obj_cls - if optional_return: - check_type = Optional[obj_cls] - assert check_type == signature.return_annotation, fail_message