diff options
author | John L. Villalovos <john@sodarock.com> | 2021-03-07 11:31:23 -0800 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2021-04-17 17:09:41 +0200 |
commit | aee1f496c1f414c1e30909767d53ae624fe875e7 (patch) | |
tree | 04a7fe9d8f77cffeae733bb8dd3447911995f3a1 /gitlab/v4/objects/projects.py | |
parent | 8603248f73d8c751023fbfd2a394c5b7d939af7f (diff) | |
download | gitlab-aee1f496c1f414c1e30909767d53ae624fe875e7.tar.gz |
chore: have _create_attrs & _update_attrs be a namedtuple
Convert _create_attrs and _update_attrs to use a NamedTuple
(RequiredOptional) to help with code readability. Update all code to
use the NamedTuple.
Diffstat (limited to 'gitlab/v4/objects/projects.py')
-rw-r--r-- | gitlab/v4/objects/projects.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py index c187ba9..b18d6f1 100644 --- a/gitlab/v4/objects/projects.py +++ b/gitlab/v4/objects/projects.py @@ -1,6 +1,6 @@ from gitlab import cli, types, utils from gitlab import exceptions as exc -from gitlab.base import RESTManager, RESTObject +from gitlab.base import RequiredOptional, RESTManager, RESTObject from gitlab.mixins import ( CRUDMixin, CreateMixin, @@ -558,9 +558,8 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO class ProjectManager(CRUDMixin, RESTManager): _path = "/projects" _obj_cls = Project - _create_attrs = ( - tuple(), - ( + _create_attrs = RequiredOptional( + optional=( "name", "path", "namespace_id", @@ -617,9 +616,8 @@ class ProjectManager(CRUDMixin, RESTManager): "packages_enabled", ), ) - _update_attrs = ( - tuple(), - ( + _update_attrs = RequiredOptional( + optional=( "name", "path", "default_branch", @@ -919,7 +917,7 @@ class ProjectForkManager(CreateMixin, ListMixin, RESTManager): "with_issues_enabled", "with_merge_requests_enabled", ) - _create_attrs = (tuple(), ("namespace",)) + _create_attrs = RequiredOptional(optional=("namespace",)) def create(self, data, **kwargs): """Creates a new object. @@ -949,5 +947,7 @@ class ProjectRemoteMirrorManager(ListMixin, CreateMixin, UpdateMixin, RESTManage _path = "/projects/%(project_id)s/remote_mirrors" _obj_cls = ProjectRemoteMirror _from_parent_attrs = {"project_id": "id"} - _create_attrs = (("url",), ("enabled", "only_protected_branches")) - _update_attrs = (tuple(), ("enabled", "only_protected_branches")) + _create_attrs = RequiredOptional( + required=("url",), optional=("enabled", "only_protected_branches") + ) + _update_attrs = RequiredOptional(optional=("enabled", "only_protected_branches")) |