8000 style: use literals to declare data structures · python-gitlab/python-gitlab@019a40f · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 019a40f

Browse files
nejchJohnVillalovos
authored andcommitted
style: use literals to declare data structures
1 parent ae2a015 commit 019a40f

File tree

10 files changed

+17
-17
lines changed

10 files changed

+17
-17
lines changed

gitlab/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ def total(self) -> Optional[int]:
317317

318318

319319
class RequiredOptional(NamedTuple):
320-
required: Tuple[str, ...] = tuple()
321-
optional: Tuple[str, ...] = tuple()
320+
required: Tuple[str, ...] = ()
321+
optional: Tuple[str, ...] = ()
322322

323323

324324
class RESTManager:

gitlab/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252

5353
def register_custom_action(
5454
cls_names: Union[str, Tuple[str, ...]],
55-
mandatory: Tuple[str, ...] = tuple(),
56-
optional: Tuple[str, ...] = tuple(),
55+
mandatory: Tuple[str, ...] = (),
56+
optional: Tuple[str, ...] = (),
5757
custom_action: Optional[str] = None,
5858
) -> Callable[[__F], __F]:
5959
def wrap(f: __F) -> __F:

gitlab/mixins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ class AccessRequestMixin(_RestObjectBase):
616616
manager: base.RESTManager
617617

618618
@cli.register_custom_action(
619-
("ProjectAccessRequest", "GroupAccessRequest"), tuple(), ("access_level",)
619+
("ProjectAccessRequest", "GroupAccessRequest"), (), ("access_level",)
620620
)
621621
@exc.on_http_error(exc.GitlabUpdateError)
622622
def approve(

gitlab/v4/objects/groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def transfer_project(self, project_id: int, **kwargs: Any) -> None:
9595
path = f"/groups/{self.encoded_id}/projects/{project_id}"
9696
self.manager.gitlab.http_post(path, **kwargs)
9797

98-
@cli.register_custom_action("Group", tuple(), ("group_id",))
98+
@cli.register_custom_action("Group", (), ("group_id",))
9999
@exc.on_http_error(exc.GitlabGroupTransferError)
100100
def transfer(self, group_id: Optional[int] = None, **kwargs: Any) -> None:
101101
"""Transfer the group to a new parent group or make it a top-level group.

gitlab/v4/objects/merge_requests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def changes(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
263263
path = f"{self.manager.path}/{self.encoded_id}/changes"
264264
return self.manager.gitlab.http_get(path, **kwargs)
265265

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

348348
@cli.register_custom_action(
349349
"ProjectMergeRequest",
350-
tuple(),
350+
(),
351351
(
352352
"merge_commit_message",
353353
"should_remove_source_branch",

gitlab/v4/objects/repositories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def update_submodule(
4646
data["commit_message"] = kwargs["commit_message"]
4747
return self.manager.gitlab.http_put(path, post_data=data)
4848

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

189-
@cli.register_custom_action("Project", tuple(), ("sha", "format"))
189+
@cli.register_custom_action("Project", (), ("sha", "format"))
190190
@exc.on_http_error(exc.GitlabListError)
191191
def repository_archive(
192192
self,

gitlab/v4/objects/runners.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class RunnerManager(CRUDMixin, RESTManager):
7070
_list_filters = ("scope", "tag_list")
7171
_types = {"tag_list": types.CommaSeparatedListAttribute}
7272

73-
@cli.register_custom_action("RunnerManager", tuple(), ("scope",))
73+
@cli.register_custom_action("RunnerManager", (), ("scope",))
7474
@exc.on_http_error(exc.GitlabListError)
7575
def all(self, scope: Optional[str] = None, **kwargs: Any) -> List[Runner]:
7676
"""List all the runners.

gitlab/v4/objects/services.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
9696
"pipeline_events",
9797
),
9898
),
99-
"external-wiki": (("external_wiki_url",), tuple()),
99+
"external-wiki": (("external_wiki_url",), ()),
100100
"flowdock": (("token",), ("push_events",)),
101101
"github": (("token", "repository_url"), ("static_context",)),
102102
"hangouts-chat": (
@@ -159,7 +159,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
159159
"comment_on_event_enabled",
160160
),
161161
),
162-
"slack-slash-commands": (("token",), tuple()),
162+
"slack-slash-commands": (("token",), ()),
163163
"mattermost-slash-commands": (("token",), ("username",)),
164164
"packagist": (
165165
("username", "token"),
@@ -194,7 +194,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
194194
),
195195
),
196196
"pivotaltracker": (("token",), ("restrict_to_branch", "push_events")),
197-
"prometheus": (("api_url",), tuple()),
197+
"prometheus": (("api_url",), ()),
198198
"pushover": (
199199
("api_key", "user_key", "priority"),
200200
("device", "sound", "push_events"),
@@ -257,7 +257,7 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
257257
("push_events",),
258258
),
259259
"jenkins": (("jenkins_url", "project_name"), ("username", "password")),
260-
"mock-ci": (("mock_service_url",), tuple()),
260+
"mock-ci": (("mock_service_url",), ()),
261261
"youtrack": (("issues_url", "project_url"), ("description", "push_events")),
262262
}
263263

tests/functional/api/test_gitlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_rate_limits(gl):
164164
settings.throttle_authenticated_api_period_in_seconds = 3
165165
settings.save()
166166

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

tests/functional/api/test_projects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def test_project_groups_list(gl, group):
328328

329329
groups = project.groups.list()
330330
group_ids = set([x.id for x in groups])
331-
assert set((group.id, group2.id)) == group_ids
331+
assert {group.id, group2.id} == group_ids
332332

333333

334334
def test_project_transfer(gl, project, group):

0 commit comments

Comments
 (0)
0