Skip to content

Commit

Permalink
style: use literals to declare data structures
Browse files Browse the repository at this point in the history
  • Loading branch information
nejch authored and JohnVillalovos committed Jan 23, 2022
1 parent ae2a015 commit 019a40f
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions gitlab/base.py
Expand Up @@ -317,8 +317,8 @@ def total(self) -> Optional[int]:


class RequiredOptional(NamedTuple):
required: Tuple[str, ...] = tuple()
optional: Tuple[str, ...] = tuple()
required: Tuple[str, ...] = ()
optional: Tuple[str, ...] = ()


class RESTManager:
Expand Down
4 changes: 2 additions & 2 deletions gitlab/cli.py
Expand Up @@ -52,8 +52,8 @@

def register_custom_action(
cls_names: Union[str, Tuple[str, ...]],
mandatory: Tuple[str, ...] = tuple(),
optional: Tuple[str, ...] = tuple(),
mandatory: Tuple[str, ...] = (),
optional: Tuple[str, ...] = (),
custom_action: Optional[str] = None,
) -> Callable[[__F], __F]:
def wrap(f: __F) -> __F:
Expand Down
2 changes: 1 addition & 1 deletion gitlab/mixins.py
Expand Up @@ -616,7 +616,7 @@ class AccessRequestMixin(_RestObjectBase):
manager: base.RESTManager

@cli.register_custom_action(
("ProjectAccessRequest", "GroupAccessRequest"), tuple(), ("access_level",)
("ProjectAccessRequest", "GroupAccessRequest"), (), ("access_level",)
)
@exc.on_http_error(exc.GitlabUpdateError)
def approve(
Expand Down
2 changes: 1 addition & 1 deletion gitlab/v4/objects/groups.py
Expand Up @@ -95,7 +95,7 @@ def transfer_project(self, project_id: int, **kwargs: Any) -> None:
path = f"/groups/{self.encoded_id}/projects/{project_id}"
self.manager.gitlab.http_post(path, **kwargs)

@cli.register_custom_action("Group", tuple(), ("group_id",))
@cli.register_custom_action("Group", (), ("group_id",))
@exc.on_http_error(exc.GitlabGroupTransferError)
def transfer(self, group_id: Optional[int] = None, **kwargs: Any) -> None:
"""Transfer the group to a new parent group or make it a top-level group.
Expand Down
4 changes: 2 additions & 2 deletions gitlab/v4/objects/merge_requests.py
Expand Up @@ -263,7 +263,7 @@ def changes(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
path = f"{self.manager.path}/{self.encoded_id}/changes"
return self.manager.gitlab.http_get(path, **kwargs)

@cli.register_custom_action("ProjectMergeRequest", tuple(), ("sha",))
@cli.register_custom_action("ProjectMergeRequest", (), ("sha",))
@exc.on_http_error(exc.GitlabMRApprovalError)
def approve(self, sha: Optional[str] = None, **kwargs: Any) -> Dict[str, Any]:
"""Approve the merge request.
Expand Down Expand Up @@ -347,7 +347,7 @@ def merge_ref(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:

@cli.register_custom_action(
"ProjectMergeRequest",
tuple(),
(),
(
"merge_commit_message",
"should_remove_source_branch",
Expand Down
4 changes: 2 additions & 2 deletions gitlab/v4/objects/repositories.py
Expand Up @@ -46,7 +46,7 @@ def update_submodule(
data["commit_message"] = kwargs["commit_message"]
return self.manager.gitlab.http_put(path, post_data=data)

@cli.register_custom_action("Project", tuple(), ("path", "ref", "recursive"))
@cli.register_custom_action("Project", (), ("path", "ref", "recursive"))
@exc.on_http_error(exc.GitlabGetError)
def repository_tree(
self, path: str = "", ref: str = "", recursive: bool = False, **kwargs: Any
Expand Down Expand Up @@ -186,7 +186,7 @@ def repository_contributors(
path = f"/projects/{self.encoded_id}/repository/contributors"
return self.manager.gitlab.http_list(path, **kwargs)

@cli.register_custom_action("Project", tuple(), ("sha", "format"))
@cli.register_custom_action("Project", (), ("sha", "format"))
@exc.on_http_error(exc.GitlabListError)
def repository_archive(
self,
Expand Down
2 changes: 1 addition & 1 deletion gitlab/v4/objects/runners.py
Expand Up @@ -70,7 +70,7 @@ class RunnerManager(CRUDMixin, RESTManager):
_list_filters = ("scope", "tag_list")
_types = {"tag_list": types.CommaSeparatedListAttribute}

@cli.register_custom_action("RunnerManager", tuple(), ("scope",))
@cli.register_custom_action("RunnerManager", (), ("scope",))
@exc.on_http_error(exc.GitlabListError)
def all(self, scope: Optional[str] = None, **kwargs: Any) -> List[Runner]:
"""List all the runners.
Expand Down
8 changes: 4 additions & 4 deletions gitlab/v4/objects/services.py
Expand Up @@ -96,7 +96,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
"pipeline_events",
),
),
"external-wiki": (("external_wiki_url",), tuple()),
"external-wiki": (("external_wiki_url",), ()),
"flowdock": (("token",), ("push_events",)),
"github": (("token", "repository_url"), ("static_context",)),
"hangouts-chat": (
Expand Down Expand Up @@ -159,7 +159,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
"comment_on_event_enabled",
),
),
"slack-slash-commands": (("token",), tuple()),
"slack-slash-commands": (("token",), ()),
"mattermost-slash-commands": (("token",), ("username",)),
"packagist": (
("username", "token"),
Expand Down Expand Up @@ -194,7 +194,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
),
),
"pivotaltracker": (("token",), ("restrict_to_branch", "push_events")),
"prometheus": (("api_url",), tuple()),
"prometheus": (("api_url",), ()),
"pushover": (
("api_key", "user_key", "priority"),
("device", "sound", "push_events"),
Expand Down Expand Up @@ -257,7 +257,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
("push_events",),
),
"jenkins": (("jenkins_url", "project_name"), ("username", "password")),
"mock-ci": (("mock_service_url",), tuple()),
"mock-ci": (("mock_service_url",), ()),
"youtrack": (("issues_url", "project_url"), ("description", "push_events")),
}

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/api/test_gitlab.py
Expand Up @@ -164,7 +164,7 @@ def test_rate_limits(gl):
settings.throttle_authenticated_api_period_in_seconds = 3
settings.save()

projects = list()
projects = []
for i in range(0, 20):
projects.append(gl.projects.create({"name": f"{str(i)}ok"}))

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/api/test_projects.py
Expand Up @@ -328,7 +328,7 @@ def test_project_groups_list(gl, group):

groups = project.groups.list()
group_ids = set([x.id for x in groups])
assert set((group.id, group2.id)) == group_ids
assert {group.id, group2.id} == group_ids


def test_project_transfer(gl, project, group):
Expand Down

0 comments on commit 019a40f

Please sign in to comment.