diff --git a/gitlab/base.py b/gitlab/base.py index a1cd30fda..8a5da4d7f 100644 --- a/gitlab/base.py +++ b/gitlab/base.py @@ -18,9 +18,8 @@ import importlib import pprint import textwrap -from dataclasses import dataclass from types import ModuleType -from typing import Any, Dict, Iterable, Optional, Tuple, Type, Union +from typing import Any, Dict, Iterable, Optional, Type, Union import gitlab from gitlab import types as g_types @@ -29,7 +28,6 @@ from .client import Gitlab, GitlabList __all__ = [ - "RequiredOptional", "RESTObject", "RESTObjectList", "RESTManager", @@ -330,12 +328,6 @@ def total(self) -> Optional[int]: return self._list.total -@dataclass(frozen=True) -class RequiredOptional: - required: Tuple[str, ...] = () - optional: Tuple[str, ...] = () - - class RESTManager: """Base class for CRUD operations on objects. @@ -345,8 +337,8 @@ class RESTManager: ``_obj_cls``: The class of objects that will be created """ - _create_attrs: RequiredOptional = RequiredOptional() - _update_attrs: RequiredOptional = RequiredOptional() + _create_attrs: g_types.RequiredOptional = g_types.RequiredOptional() + _update_attrs: g_types.RequiredOptional = g_types.RequiredOptional() _path: Optional[str] = None _obj_cls: Optional[Type[RESTObject]] = None _from_parent_attrs: Dict[str, Any] = {} diff --git a/gitlab/types.py b/gitlab/types.py index bf74f2e8a..f2cdb7231 100644 --- a/gitlab/types.py +++ b/gitlab/types.py @@ -15,7 +15,14 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . -from typing import Any, Optional, TYPE_CHECKING +import dataclasses +from typing import Any, Optional, Tuple, TYPE_CHECKING + + +@dataclasses.dataclass(frozen=True) +class RequiredOptional: + required: Tuple[str, ...] = () + optional: Tuple[str, ...] = () class GitlabAttribute: diff --git a/gitlab/v4/objects/appearance.py b/gitlab/v4/objects/appearance.py index 6a1f97455..db4b551ed 100644 --- a/gitlab/v4/objects/appearance.py +++ b/gitlab/v4/objects/appearance.py @@ -1,8 +1,9 @@ from typing import Any, cast, Dict, Optional, Union from gitlab import exceptions as exc -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import GetWithoutIdMixin, SaveMixin, UpdateMixin +from gitlab.types import RequiredOptional __all__ = [ "ApplicationAppearance", diff --git a/gitlab/v4/objects/applications.py b/gitlab/v4/objects/applications.py index 926d18915..921bd0e08 100644 --- a/gitlab/v4/objects/applications.py +++ b/gitlab/v4/objects/applications.py @@ -1,5 +1,6 @@ -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin +from gitlab.types import RequiredOptional __all__ = [ "Application", diff --git a/gitlab/v4/objects/award_emojis.py b/gitlab/v4/objects/award_emojis.py index 3f9d77704..cddf97f1b 100644 --- a/gitlab/v4/objects/award_emojis.py +++ b/gitlab/v4/objects/award_emojis.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin +from gitlab.types import RequiredOptional __all__ = [ "GroupEpicAwardEmoji", diff --git a/gitlab/v4/objects/badges.py b/gitlab/v4/objects/badges.py index 4dee75ac0..3df5d0b28 100644 --- a/gitlab/v4/objects/badges.py +++ b/gitlab/v4/objects/badges.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import BadgeRenderMixin, CRUDMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "GroupBadge", diff --git a/gitlab/v4/objects/boards.py b/gitlab/v4/objects/boards.py index 73c652b1c..a5c59b3ca 100644 --- a/gitlab/v4/objects/boards.py +++ b/gitlab/v4/objects/boards.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "GroupBoardList", diff --git a/gitlab/v4/objects/branches.py b/gitlab/v4/objects/branches.py index d06d6b44f..8c6e86ce5 100644 --- a/gitlab/v4/objects/branches.py +++ b/gitlab/v4/objects/branches.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin +from gitlab.types import RequiredOptional __all__ = [ "ProjectBranch", diff --git a/gitlab/v4/objects/broadcast_messages.py b/gitlab/v4/objects/broadcast_messages.py index 7e28be6ee..3beb4ace0 100644 --- a/gitlab/v4/objects/broadcast_messages.py +++ b/gitlab/v4/objects/broadcast_messages.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "BroadcastMessage", diff --git a/gitlab/v4/objects/clusters.py b/gitlab/v4/objects/clusters.py index dc02ee050..d51a97a7b 100644 --- a/gitlab/v4/objects/clusters.py +++ b/gitlab/v4/objects/clusters.py @@ -1,8 +1,9 @@ from typing import Any, cast, Dict, Optional, Union from gitlab import exceptions as exc -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, CRUDMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "GroupCluster", diff --git a/gitlab/v4/objects/commits.py b/gitlab/v4/objects/commits.py index 19098af0b..8558ef9ea 100644 --- a/gitlab/v4/objects/commits.py +++ b/gitlab/v4/objects/commits.py @@ -5,8 +5,9 @@ import gitlab from gitlab import cli from gitlab import exceptions as exc -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, ListMixin, RefreshMixin, RetrieveMixin +from gitlab.types import RequiredOptional from .discussions import ProjectCommitDiscussionManager # noqa: F401 diff --git a/gitlab/v4/objects/deploy_keys.py b/gitlab/v4/objects/deploy_keys.py index f325f691c..0962b4a39 100644 --- a/gitlab/v4/objects/deploy_keys.py +++ b/gitlab/v4/objects/deploy_keys.py @@ -4,8 +4,9 @@ from gitlab import cli from gitlab import exceptions as exc -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "DeployKey", diff --git a/gitlab/v4/objects/deploy_tokens.py b/gitlab/v4/objects/deploy_tokens.py index 9fcfc2314..32bb5fed1 100644 --- a/gitlab/v4/objects/deploy_tokens.py +++ b/gitlab/v4/objects/deploy_tokens.py @@ -1,7 +1,7 @@ from typing import Any, cast, Union from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, DeleteMixin, @@ -9,6 +9,7 @@ ObjectDeleteMixin, RetrieveMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "DeployToken", diff --git a/gitlab/v4/objects/deployments.py b/gitlab/v4/objects/deployments.py index 9aee699c9..a431603be 100644 --- a/gitlab/v4/objects/deployments.py +++ b/gitlab/v4/objects/deployments.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, RetrieveMixin, SaveMixin, UpdateMixin +from gitlab.types import RequiredOptional from .merge_requests import ProjectDeploymentMergeRequestManager # noqa: F401 diff --git a/gitlab/v4/objects/discussions.py b/gitlab/v4/objects/discussions.py index fa874c436..9cfce7211 100644 --- a/gitlab/v4/objects/discussions.py +++ b/gitlab/v4/objects/discussions.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, RetrieveMixin, SaveMixin, UpdateMixin +from gitlab.types import RequiredOptional from .notes import ( # noqa: F401 ProjectCommitDiscussionNoteManager, diff --git a/gitlab/v4/objects/environments.py b/gitlab/v4/objects/environments.py index 681e7ee70..7e2089fb6 100644 --- a/gitlab/v4/objects/environments.py +++ b/gitlab/v4/objects/environments.py @@ -4,7 +4,7 @@ from gitlab import cli from gitlab import exceptions as exc -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, DeleteMixin, @@ -13,6 +13,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "ProjectEnvironment", diff --git a/gitlab/v4/objects/epics.py b/gitlab/v4/objects/epics.py index d33821c15..76dadf20f 100644 --- a/gitlab/v4/objects/epics.py +++ b/gitlab/v4/objects/epics.py @@ -2,7 +2,7 @@ from gitlab import exceptions as exc from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, CRUDMixin, @@ -12,6 +12,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional from .events import GroupEpicResourceLabelEventManager # noqa: F401 diff --git a/gitlab/v4/objects/export_import.py b/gitlab/v4/objects/export_import.py index 49c9e0c6c..a275164ac 100644 --- a/gitlab/v4/objects/export_import.py +++ b/gitlab/v4/objects/export_import.py @@ -1,7 +1,8 @@ from typing import Any, cast, Optional, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, DownloadMixin, GetWithoutIdMixin, RefreshMixin +from gitlab.types import RequiredOptional __all__ = [ "GroupExport", diff --git a/gitlab/v4/objects/files.py b/gitlab/v4/objects/files.py index e5345ce15..c0b72616d 100644 --- a/gitlab/v4/objects/files.py +++ b/gitlab/v4/objects/files.py @@ -6,7 +6,7 @@ from gitlab import cli from gitlab import exceptions as exc from gitlab import utils -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, DeleteMixin, @@ -15,6 +15,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "ProjectFile", diff --git a/gitlab/v4/objects/geo_nodes.py b/gitlab/v4/objects/geo_nodes.py index 663327568..70e9f71aa 100644 --- a/gitlab/v4/objects/geo_nodes.py +++ b/gitlab/v4/objects/geo_nodes.py @@ -2,7 +2,7 @@ from gitlab import cli from gitlab import exceptions as exc -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( DeleteMixin, ObjectDeleteMixin, @@ -10,6 +10,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "GeoNode", diff --git a/gitlab/v4/objects/groups.py b/gitlab/v4/objects/groups.py index 28f3623ed..33f5be16b 100644 --- a/gitlab/v4/objects/groups.py +++ b/gitlab/v4/objects/groups.py @@ -6,8 +6,9 @@ from gitlab import cli from gitlab import exceptions as exc from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional from .access_requests import GroupAccessRequestManager # noqa: F401 from .audit_events import GroupAuditEventManager # noqa: F401 diff --git a/gitlab/v4/objects/hooks.py b/gitlab/v4/objects/hooks.py index f37d514bc..aa0ff0368 100644 --- a/gitlab/v4/objects/hooks.py +++ b/gitlab/v4/objects/hooks.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, NoUpdateMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "Hook", diff --git a/gitlab/v4/objects/issues.py b/gitlab/v4/objects/issues.py index 693c18f3b..e368357af 100644 --- a/gitlab/v4/objects/issues.py +++ b/gitlab/v4/objects/issues.py @@ -3,7 +3,7 @@ from gitlab import cli from gitlab import exceptions as exc from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, CRUDMixin, @@ -18,6 +18,7 @@ TodoMixin, UserAgentDetailMixin, ) +from gitlab.types import RequiredOptional from .award_emojis import ProjectIssueAwardEmojiManager # noqa: F401 from .discussions import ProjectIssueDiscussionManager # noqa: F401 diff --git a/gitlab/v4/objects/labels.py b/gitlab/v4/objects/labels.py index 165bdb9b2..68f37b30e 100644 --- a/gitlab/v4/objects/labels.py +++ b/gitlab/v4/objects/labels.py @@ -1,7 +1,7 @@ from typing import Any, cast, Dict, Optional, Union from gitlab import exceptions as exc -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, DeleteMixin, @@ -12,6 +12,7 @@ SubscribableMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "GroupLabel", diff --git a/gitlab/v4/objects/members.py b/gitlab/v4/objects/members.py index d5d8766d9..af25085ec 100644 --- a/gitlab/v4/objects/members.py +++ b/gitlab/v4/objects/members.py @@ -1,7 +1,7 @@ from typing import Any, cast, Union from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CRUDMixin, DeleteMixin, @@ -10,6 +10,7 @@ RetrieveMixin, SaveMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "GroupBillableMember", diff --git a/gitlab/v4/objects/merge_request_approvals.py b/gitlab/v4/objects/merge_request_approvals.py index f23fcf074..36224d19b 100644 --- a/gitlab/v4/objects/merge_request_approvals.py +++ b/gitlab/v4/objects/merge_request_approvals.py @@ -1,7 +1,7 @@ from typing import Any, cast, Dict, List, Optional, TYPE_CHECKING, Union from gitlab import exceptions as exc -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, DeleteMixin, @@ -11,6 +11,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "ProjectApproval", diff --git a/gitlab/v4/objects/merge_requests.py b/gitlab/v4/objects/merge_requests.py index a3c583bb5..9eb965b93 100644 --- a/gitlab/v4/objects/merge_requests.py +++ b/gitlab/v4/objects/merge_requests.py @@ -11,7 +11,7 @@ from gitlab import cli from gitlab import exceptions as exc from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject, RESTObjectList +from gitlab.base import RESTManager, RESTObject, RESTObjectList from gitlab.mixins import ( CRUDMixin, ListMixin, @@ -23,6 +23,7 @@ TimeTrackingMixin, TodoMixin, ) +from gitlab.types import RequiredOptional from .award_emojis import ProjectMergeRequestAwardEmojiManager # noqa: F401 from .commits import ProjectCommit, ProjectCommitManager diff --git a/gitlab/v4/objects/milestones.py b/gitlab/v4/objects/milestones.py index 0c4d74b59..2d82a59c7 100644 --- a/gitlab/v4/objects/milestones.py +++ b/gitlab/v4/objects/milestones.py @@ -3,8 +3,9 @@ from gitlab import cli from gitlab import exceptions as exc from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject, RESTObjectList +from gitlab.base import RESTManager, RESTObject, RESTObjectList from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, PromoteMixin, SaveMixin +from gitlab.types import RequiredOptional from .issues import GroupIssue, GroupIssueManager, ProjectIssue, ProjectIssueManager from .merge_requests import ( diff --git a/gitlab/v4/objects/notes.py b/gitlab/v4/objects/notes.py index 833f63226..06605bce1 100644 --- a/gitlab/v4/objects/notes.py +++ b/gitlab/v4/objects/notes.py @@ -1,6 +1,6 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, CRUDMixin, @@ -11,6 +11,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional from .award_emojis import ( # noqa: F401 GroupEpicNoteAwardEmojiManager, diff --git a/gitlab/v4/objects/notification_settings.py b/gitlab/v4/objects/notification_settings.py index 4dd8347c8..d3cd4cbae 100644 --- a/gitlab/v4/objects/notification_settings.py +++ b/gitlab/v4/objects/notification_settings.py @@ -1,7 +1,8 @@ from typing import Any, cast, Optional, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import GetWithoutIdMixin, SaveMixin, UpdateMixin +from gitlab.types import RequiredOptional __all__ = [ "NotificationSettings", diff --git a/gitlab/v4/objects/pages.py b/gitlab/v4/objects/pages.py index 3fc0404da..ed0ed3e0b 100644 --- a/gitlab/v4/objects/pages.py +++ b/gitlab/v4/objects/pages.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "PagesDomain", diff --git a/gitlab/v4/objects/personal_access_tokens.py b/gitlab/v4/objects/personal_access_tokens.py index 74ba231cf..5e4e54bd5 100644 --- a/gitlab/v4/objects/personal_access_tokens.py +++ b/gitlab/v4/objects/personal_access_tokens.py @@ -1,5 +1,6 @@ -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin, DeleteMixin, ListMixin, ObjectDeleteMixin +from gitlab.types import RequiredOptional __all__ = [ "PersonalAccessToken", diff --git a/gitlab/v4/objects/pipelines.py b/gitlab/v4/objects/pipelines.py index 480b8c06b..0db82a34d 100644 --- a/gitlab/v4/objects/pipelines.py +++ b/gitlab/v4/objects/pipelines.py @@ -4,7 +4,7 @@ from gitlab import cli from gitlab import exceptions as exc -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, CRUDMixin, @@ -17,6 +17,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "ProjectMergeRequestPipeline", diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py index 6eaacf3b7..8674ee635 100644 --- a/gitlab/v4/objects/projects.py +++ b/gitlab/v4/objects/projects.py @@ -5,7 +5,7 @@ from gitlab import cli, client from gitlab import exceptions as exc from gitlab import types, utils -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, CRUDMixin, @@ -16,6 +16,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional from .access_requests import ProjectAccessRequestManager # noqa: F401 from .artifacts import ProjectArtifactManager # noqa: F401 diff --git a/gitlab/v4/objects/push_rules.py b/gitlab/v4/objects/push_rules.py index 4adfc2e9c..ce75eacce 100644 --- a/gitlab/v4/objects/push_rules.py +++ b/gitlab/v4/objects/push_rules.py @@ -1,6 +1,6 @@ from typing import Any, cast, Optional, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, DeleteMixin, @@ -9,6 +9,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "ProjectPushRules", diff --git a/gitlab/v4/objects/releases.py b/gitlab/v4/objects/releases.py index e14f42a90..788c05091 100644 --- a/gitlab/v4/objects/releases.py +++ b/gitlab/v4/objects/releases.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "ProjectRelease", diff --git a/gitlab/v4/objects/runners.py b/gitlab/v4/objects/runners.py index 51f68611a..4f9d7ce57 100644 --- a/gitlab/v4/objects/runners.py +++ b/gitlab/v4/objects/runners.py @@ -3,7 +3,7 @@ from gitlab import cli from gitlab import exceptions as exc from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( CreateMixin, CRUDMixin, @@ -12,6 +12,7 @@ ObjectDeleteMixin, SaveMixin, ) +from gitlab.types import RequiredOptional __all__ = [ "RunnerJob", diff --git a/gitlab/v4/objects/settings.py b/gitlab/v4/objects/settings.py index 071f7e464..6171833d3 100644 --- a/gitlab/v4/objects/settings.py +++ b/gitlab/v4/objects/settings.py @@ -2,8 +2,9 @@ from gitlab import exceptions as exc from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import GetWithoutIdMixin, SaveMixin, UpdateMixin +from gitlab.types import RequiredOptional __all__ = [ "ApplicationSettings", diff --git a/gitlab/v4/objects/snippets.py b/gitlab/v4/objects/snippets.py index 83b1378e2..597a3aaf0 100644 --- a/gitlab/v4/objects/snippets.py +++ b/gitlab/v4/objects/snippets.py @@ -5,8 +5,9 @@ from gitlab import cli from gitlab import exceptions as exc from gitlab import utils -from gitlab.base import RequiredOptional, RESTManager, RESTObject, RESTObjectList +from gitlab.base import RESTManager, RESTObject, RESTObjectList from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin, UserAgentDetailMixin +from gitlab.types import RequiredOptional from .award_emojis import ProjectSnippetAwardEmojiManager # noqa: F401 from .discussions import ProjectSnippetDiscussionManager # noqa: F401 diff --git a/gitlab/v4/objects/tags.py b/gitlab/v4/objects/tags.py index 748cbad97..43342649f 100644 --- a/gitlab/v4/objects/tags.py +++ b/gitlab/v4/objects/tags.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin +from gitlab.types import RequiredOptional __all__ = [ "ProjectTag", diff --git a/gitlab/v4/objects/topics.py b/gitlab/v4/objects/topics.py index 76208ed82..57b104ee5 100644 --- a/gitlab/v4/objects/topics.py +++ b/gitlab/v4/objects/topics.py @@ -1,8 +1,9 @@ from typing import Any, cast, Union from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "Topic", diff --git a/gitlab/v4/objects/triggers.py b/gitlab/v4/objects/triggers.py index e75be1355..8c0d88536 100644 --- a/gitlab/v4/objects/triggers.py +++ b/gitlab/v4/objects/triggers.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "ProjectTrigger", diff --git a/gitlab/v4/objects/users.py b/gitlab/v4/objects/users.py index 81a8aaa61..acd3b2f76 100644 --- a/gitlab/v4/objects/users.py +++ b/gitlab/v4/objects/users.py @@ -10,7 +10,7 @@ from gitlab import cli from gitlab import exceptions as exc from gitlab import types -from gitlab.base import RequiredOptional, RESTManager, RESTObject, RESTObjectList +from gitlab.base import RESTManager, RESTObject, RESTObjectList from gitlab.mixins import ( CreateMixin, CRUDMixin, @@ -23,6 +23,7 @@ SaveMixin, UpdateMixin, ) +from gitlab.types import RequiredOptional from .custom_attributes import UserCustomAttributeManager # noqa: F401 from .events import UserEventManager # noqa: F401 diff --git a/gitlab/v4/objects/variables.py b/gitlab/v4/objects/variables.py index ba425c817..62ea872de 100644 --- a/gitlab/v4/objects/variables.py +++ b/gitlab/v4/objects/variables.py @@ -6,8 +6,9 @@ """ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "Variable", diff --git a/gitlab/v4/objects/wikis.py b/gitlab/v4/objects/wikis.py index a7028cfe6..712b7339e 100644 --- a/gitlab/v4/objects/wikis.py +++ b/gitlab/v4/objects/wikis.py @@ -1,7 +1,8 @@ from typing import Any, cast, Union -from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin +from gitlab.types import RequiredOptional __all__ = [ "ProjectWiki", diff --git a/tests/unit/mixins/test_mixin_methods.py b/tests/unit/mixins/test_mixin_methods.py index c0b0a580b..3c2454e66 100644 --- a/tests/unit/mixins/test_mixin_methods.py +++ b/tests/unit/mixins/test_mixin_methods.py @@ -2,6 +2,7 @@ import responses from gitlab import base +from gitlab import types as gl_types from gitlab.mixins import ( CreateMixin, DeleteMixin, @@ -166,7 +167,7 @@ class M(ListMixin, FakeManager): def test_create_mixin_missing_attrs(gl): class M(CreateMixin, FakeManager): - _create_attrs = base.RequiredOptional( + _create_attrs = gl_types.RequiredOptional( required=("foo",), optional=("bar", "baz") ) @@ -183,10 +184,10 @@ class M(CreateMixin, FakeManager): @responses.activate def test_create_mixin(gl): class M(CreateMixin, FakeManager): - _create_attrs = base.RequiredOptional( + _create_attrs = gl_types.RequiredOptional( required=("foo",), optional=("bar", "baz") ) - _update_attrs = base.RequiredOptional(required=("foo",), optional=("bam",)) + _update_attrs = gl_types.RequiredOptional(required=("foo",), optional=("bam",)) url = "http://localhost/api/v4/tests" responses.add( @@ -208,10 +209,10 @@ class M(CreateMixin, FakeManager): @responses.activate def test_create_mixin_custom_path(gl): class M(CreateMixin, FakeManager): - _create_attrs = base.RequiredOptional( + _create_attrs = gl_types.RequiredOptional( required=("foo",), optional=("bar", "baz") ) - _update_attrs = base.RequiredOptional(required=("foo",), optional=("bam",)) + _update_attrs = gl_types.RequiredOptional(required=("foo",), optional=("bam",)) url = "http://localhost/api/v4/others" responses.add( @@ -232,7 +233,7 @@ class M(CreateMixin, FakeManager): def test_update_mixin_missing_attrs(gl): class M(UpdateMixin, FakeManager): - _update_attrs = base.RequiredOptional( + _update_attrs = gl_types.RequiredOptional( required=("foo",), optional=("bar", "baz") ) @@ -249,10 +250,10 @@ class M(UpdateMixin, FakeManager): @responses.activate def test_update_mixin(gl): class M(UpdateMixin, FakeManager): - _create_attrs = base.RequiredOptional( + _create_attrs = gl_types.RequiredOptional( required=("foo",), optional=("bar", "baz") ) - _update_attrs = base.RequiredOptional(required=("foo",), optional=("bam",)) + _update_attrs = gl_types.RequiredOptional(required=("foo",), optional=("bam",)) url = "http://localhost/api/v4/tests/42" responses.add( @@ -293,10 +294,10 @@ class M(UpdateMixin, FakeManager): @responses.activate def test_update_mixin_no_id(gl): class M(UpdateMixin, FakeManager): - _create_attrs = base.RequiredOptional( + _create_attrs = gl_types.RequiredOptional( required=("foo",), optional=("bar", "baz") ) - _update_attrs = base.RequiredOptional(required=("foo",), optional=("bam",)) + _update_attrs = gl_types.RequiredOptional(required=("foo",), optional=("bam",)) url = "http://localhost/api/v4/tests" responses.add(