Skip to content

Commit 665b2c8

Browse files
test(pylint): enable pylint "unused-argument" check
Enable the pylint "unused-argument" check and resolve issues it found. * Quite a few functions were accepting `**kwargs` but not then passing them on through to the next level. Now pass `**kwargs` to next level. * Other functions had no reason to accept `**kwargs`, so remove it * And a few other fixes.
1 parent b644721 commit 665b2c8

File tree

9 files changed

+18
-15
lines changed

9 files changed

+18
-15
lines changed

gitlab/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ def http_post(
967967
query_data=query_data,
968968
post_data=post_data,
969969
files=files,
970+
raw=raw,
970971
**kwargs,
971972
)
972973
try:

gitlab/v4/cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ def get_dict(
382382
class JSONPrinter:
383383
@staticmethod
384384
def display(d: Union[str, Dict[str, Any]], **kwargs: Any) -> None:
385+
_ = kwargs # Disables PyLint 'unused-argument' error
385386
import json # noqa
386387

387388
print(json.dumps(d))
@@ -392,6 +393,7 @@ def display_list(
392393
fields: List[str],
393394
**kwargs: Any,
394395
) -> None:
396+
_ = kwargs # Disables PyLint 'unused-argument' error
395397
import json # noqa
396398

397399
print(json.dumps([get_dict(obj, fields) for obj in data]))
@@ -400,6 +402,7 @@ def display_list(
400402
class YAMLPrinter:
401403
@staticmethod
402404
def display(d: Union[str, Dict[str, Any]], **kwargs: Any) -> None:
405+
_ = kwargs # Disables PyLint 'unused-argument' error
403406
try:
404407
import yaml # noqa
405408

@@ -417,6 +420,7 @@ def display_list(
417420
fields: List[str],
418421
**kwargs: Any,
419422
) -> None:
423+
_ = kwargs # Disables PyLint 'unused-argument' error
420424
try:
421425
import yaml # noqa
422426

@@ -435,6 +439,7 @@ def display_list(
435439

436440
class LegacyPrinter:
437441
def display(self, d: Union[str, Dict[str, Any]], **kwargs: Any) -> None:
442+
_ = d # Disables PyLint 'unused-argument' error
438443
verbose = kwargs.get("verbose", False)
439444
padding = kwargs.get("padding", 0)
440445
obj: Optional[Union[Dict[str, Any], gitlab.base.RESTObject]] = kwargs.get("obj")

gitlab/v4/objects/groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def delete_ldap_group_link(
183183
if provider is not None:
184184
path += f"/{provider}"
185185
path += f"/{cn}"
186-
self.manager.gitlab.http_delete(path)
186+
self.manager.gitlab.http_delete(path, **kwargs)
187187

188188
@cli.register_custom_action("Group")
189189
@exc.on_http_error(exc.GitlabCreateError)

gitlab/v4/objects/jobs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def cancel(self, **kwargs: Any) -> Dict[str, Any]:
2828
GitlabJobCancelError: If the job could not be canceled
2929
"""
3030
path = f"{self.manager.path}/{self.encoded_id}/cancel"
31-
result = self.manager.gitlab.http_post(path)
31+
result = self.manager.gitlab.http_post(path, **kwargs)
3232
if TYPE_CHECKING:
3333
assert isinstance(result, dict)
3434
return result
@@ -46,7 +46,7 @@ def retry(self, **kwargs: Any) -> Dict[str, Any]:
4646
GitlabJobRetryError: If the job could not be retried
4747
"""
4848
path = f"{self.manager.path}/{self.encoded_id}/retry"
49-
result = self.manager.gitlab.http_post(path)
49+
result = self.manager.gitlab.http_post(path, **kwargs)
5050
if TYPE_CHECKING:
5151
assert isinstance(result, dict)
5252
return result
@@ -64,7 +64,7 @@ def play(self, **kwargs: Any) -> None:
6464
GitlabJobPlayError: If the job could not be triggered
6565
"""
6666
path = f"{self.manager.path}/{self.encoded_id}/play"
67-
self.manager.gitlab.http_post(path)
67+
self.manager.gitlab.http_post(path, **kwargs)
6868

6969
@cli.register_custom_action("ProjectJob")
7070
@exc.on_http_error(exc.GitlabJobEraseError)
@@ -79,7 +79,7 @@ def erase(self, **kwargs: Any) -> None:
7979
GitlabJobEraseError: If the job could not be erased
8080
"""
8181
path = f"{self.manager.path}/{self.encoded_id}/erase"
82-
self.manager.gitlab.http_post(path)
82+
self.manager.gitlab.http_post(path, **kwargs)
8383

8484
@cli.register_custom_action("ProjectJob")
8585
@exc.on_http_error(exc.GitlabCreateError)
@@ -94,7 +94,7 @@ def keep_artifacts(self, **kwargs: Any) -> None:
9494
GitlabCreateError: If the request could not be performed
9595
"""
9696
path = f"{self.manager.path}/{self.encoded_id}/artifacts/keep"
97-
self.manager.gitlab.http_post(path)
97+
self.manager.gitlab.http_post(path, **kwargs)
9898

9999
@cli.register_custom_action("ProjectJob")
100100
@exc.on_http_error(exc.GitlabCreateError)
@@ -109,7 +109,7 @@ def delete_artifacts(self, **kwargs: Any) -> None:
109109
GitlabDeleteError: If the request could not be performed
110110
"""
111111
path = f"{self.manager.path}/{self.encoded_id}/artifacts"
112-
self.manager.gitlab.http_delete(path)
112+
self.manager.gitlab.http_delete(path, **kwargs)
113113

114114
@cli.register_custom_action("ProjectJob")
115115
@exc.on_http_error(exc.GitlabGetError)

gitlab/v4/objects/merge_request_approvals.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ def set_approvers(
119119
approver_ids: Optional[List[int]] = None,
120120
approver_group_ids: Optional[List[int]] = None,
121121
approval_rule_name: str = "name",
122-
**kwargs: Any,
123122
) -> RESTObject:
124123
"""Change MR-level allowed approvers and approver groups.
125124

gitlab/v4/objects/pipelines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def cancel(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
7171
GitlabPipelineCancelError: If the request failed
7272
"""
7373
path = f"{self.manager.path}/{self.encoded_id}/cancel"
74-
return self.manager.gitlab.http_post(path)
74+
return self.manager.gitlab.http_post(path, **kwargs)
7575

7676
@cli.register_custom_action("ProjectPipeline")
7777
@exc.on_http_error(exc.GitlabPipelineRetryError)
@@ -86,7 +86,7 @@ def retry(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]:
8686
GitlabPipelineRetryError: If the request failed
8787
"""
8888
path = f"{self.manager.path}/{self.encoded_id}/retry"
89-
return self.manager.gitlab.http_post(path)
89+
return self.manager.gitlab.http_post(path, **kwargs)
9090

9191

9292
class ProjectPipelineManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManager):

gitlab/v4/objects/projects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def upload(
464464

465465
url = f"/projects/{self.encoded_id}/uploads"
466466
file_info = {"file": (filename, filedata)}
467-
data = self.manager.gitlab.http_post(url, files=file_info)
467+
data = self.manager.gitlab.http_post(url, files=file_info, **kwargs)
468468

469469
if TYPE_CHECKING:
470470
assert isinstance(data, dict)
@@ -504,7 +504,7 @@ def snapshot(
504504
"""
505505
path = f"/projects/{self.encoded_id}/snapshot"
506506
result = self.manager.gitlab.http_get(
507-
path, streamed=streamed, raw=True, **kwargs
507+
path, streamed=streamed, raw=True, wiki=wiki, **kwargs
508508
)
509509
if TYPE_CHECKING:
510510
assert isinstance(result, requests.Response)

gitlab/v4/objects/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def get(
267267
return cast(ProjectService, super().get(id=id, lazy=lazy, **kwargs))
268268

269269
@cli.register_custom_action("ProjectServiceManager")
270-
def available(self, **kwargs: Any) -> List[str]:
270+
def available(self) -> List[str]:
271271
"""List the services known by python-gitlab.
272272
273273
Returns:

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ disable = [
7070
"too-many-locals",
7171
"too-many-statements",
7272
"unsubscriptable-object",
73-
"unused-argument",
74-
7573
]
7674

7775
[tool.pytest.ini_options]

0 commit comments

Comments
 (0)