Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit7a5923c

Browse files
authored
Merge pull request#2051 from python-gitlab/jlvillal/more_more_pylint
chore: enable more pylint checks
2 parents61b8beb +1324ce1 commit7a5923c

File tree

12 files changed

+38
-49
lines changed

12 files changed

+38
-49
lines changed

‎gitlab/cli.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,18 @@ def _get_base_parser(add_help: bool = True) -> argparse.ArgumentParser:
252252
def_get_parser()->argparse.ArgumentParser:
253253
# NOTE: We must delay import of gitlab.v4.cli until now or
254254
# otherwise it will cause circular import errors
255-
importgitlab.v4.cli
255+
fromgitlab.v4importcliasv4_cli
256256

257257
parser=_get_base_parser()
258-
returngitlab.v4.cli.extend_parser(parser)
258+
returnv4_cli.extend_parser(parser)
259259

260260

261261
def_parse_value(v:Any)->Any:
262262
ifisinstance(v,str)andv.startswith("@"):
263263
# If the user-provided value starts with @, we try to read the file
264264
# path provided after @ as the real value. Exit on any error.
265265
try:
266-
withopen(v[1:])asf:
266+
withopen(v[1:],encoding="utf-8")asf:
267267
returnf.read()
268268
exceptExceptionase:
269269
sys.stderr.write(f"{e}\n")

‎gitlab/client.py‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ def __init__(
119119
raiseModuleNotFoundError(f"gitlab.v{self._api_version}.objects")
120120
# NOTE: We must delay import of gitlab.v4.objects until now or
121121
# otherwise it will cause circular import errors
122-
importgitlab.v4.objects
122+
fromgitlab.v4importobjects
123123

124-
objects=gitlab.v4.objects
125124
self._objects=objects
125+
self.user:Optional[objects.CurrentUser]=None
126126

127127
self.broadcastmessages=objects.BroadcastMessageManager(self)
128128
"""See :class:`~gitlab.v4.objects.BroadcastMessageManager`"""
@@ -213,9 +213,9 @@ def __setstate__(self, state: Dict[str, Any]) -> None:
213213
)# pragma: no cover, dead code currently
214214
# NOTE: We must delay import of gitlab.v4.objects until now or
215215
# otherwise it will cause circular import errors
216-
importgitlab.v4.objects
216+
fromgitlab.v4importobjects
217217

218-
self._objects=gitlab.v4.objects
218+
self._objects=objects
219219

220220
@property
221221
defurl(self)->str:
@@ -514,7 +514,8 @@ def _set_auth_info(self) -> None:
514514
self.http_username,self.http_password
515515
)
516516

517-
defenable_debug(self)->None:
517+
@staticmethod
518+
defenable_debug()->None:
518519
importlogging
519520
fromhttp.clientimportHTTPConnection# noqa
520521

@@ -533,7 +534,8 @@ def _get_session_opts(self) -> Dict[str, Any]:
533534
"verify":self.ssl_verify,
534535
}
535536

536-
def_get_base_url(self,url:Optional[str]=None)->str:
537+
@staticmethod
538+
def_get_base_url(url:Optional[str]=None)->str:
537539
"""Return the base URL with the trailing slash stripped.
538540
If the URL is a Falsy value, return the default URL.
539541
Returns:
@@ -555,10 +557,10 @@ def _build_url(self, path: str) -> str:
555557
"""
556558
ifpath.startswith("http://")orpath.startswith("https://"):
557559
returnpath
558-
else:
559-
returnf"{self._url}{path}"
560+
returnf"{self._url}{path}"
560561

561-
def_check_redirects(self,result:requests.Response)->None:
562+
@staticmethod
563+
def_check_redirects(result:requests.Response)->None:
562564
# Check the requests history to detect 301/302 redirections.
563565
# If the initial verb is POST or PUT, the redirected request will use a
564566
# GET request, leading to unwanted behaviour.
@@ -583,8 +585,8 @@ def _check_redirects(self, result: requests.Response) -> None:
583585
)
584586
)
585587

588+
@staticmethod
586589
def_prepare_send_data(
587-
self,
588590
files:Optional[Dict[str,Any]]=None,
589591
post_data:Optional[Union[Dict[str,Any],bytes]]=None,
590592
raw:bool=False,

‎gitlab/config.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def _get_config_files(
5656
try:
5757
resolved=_resolve_file(config_file)
5858
exceptOSErrorase:
59-
raiseGitlabConfigMissingError(f"Cannot read config from file:{e}")
59+
raiseGitlabConfigMissingError(
60+
f"Cannot read config from file:{e}"
61+
)frome
6062
resolved_files.append(resolved)
6163

6264
returnresolved_files
@@ -69,7 +71,7 @@ def _get_config_files(
6971
exceptOSErrorase:
7072
raiseGitlabConfigMissingError(
7173
f"Cannot read config from PYTHON_GITLAB_CFG:{e}"
72-
)
74+
)frome
7375

7476
forconfig_filein_DEFAULT_FILES:
7577
try:

‎gitlab/exceptions.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def __init__(
4747
def__str__(self)->str:
4848
ifself.response_codeisnotNone:
4949
returnf"{self.response_code}:{self.error_message}"
50-
else:
51-
returnf"{self.error_message}"
50+
returnf"{self.error_message}"
5251

5352

5453
classGitlabAuthenticationError(GitlabError):

‎gitlab/mixins.py‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ def list(self, **kwargs: Any) -> Union[base.RESTObjectList, List[base.RESTObject
231231
obj=self.gitlab.http_list(path,**data)
232232
ifisinstance(obj,list):
233233
return [self._obj_cls(self,item,created_from_list=True)foriteminobj]
234-
else:
235-
returnbase.RESTObjectList(self,self._obj_cls,obj)
234+
returnbase.RESTObjectList(self,self._obj_cls,obj)
236235

237236

238237
classRetrieveMixin(ListMixin,GetMixin):
@@ -244,8 +243,6 @@ class RetrieveMixin(ListMixin, GetMixin):
244243
_path:Optional[str]
245244
gitlab:gitlab.Gitlab
246245

247-
pass
248-
249246

250247
classCreateMixin(_RestManagerBase):
251248
_computed_path:Optional[str]
@@ -429,8 +426,6 @@ class CRUDMixin(GetMixin, ListMixin, CreateMixin, UpdateMixin, DeleteMixin):
429426
_path:Optional[str]
430427
gitlab:gitlab.Gitlab
431428

432-
pass
433-
434429

435430
classNoUpdateMixin(GetMixin,ListMixin,CreateMixin,DeleteMixin):
436431
_computed_path:Optional[str]
@@ -441,8 +436,6 @@ class NoUpdateMixin(GetMixin, ListMixin, CreateMixin, DeleteMixin):
441436
_path:Optional[str]
442437
gitlab:gitlab.Gitlab
443438

444-
pass
445-
446439

447440
classSaveMixin(_RestObjectBase):
448441
"""Mixin for RESTObject's that can be updated."""

‎gitlab/types.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ def get_for_api(self) -> str:
103103

104104

105105
classFileAttribute(GitlabAttribute):
106-
defget_file_name(self,attr_name:Optional[str]=None)->Optional[str]:
106+
@staticmethod
107+
defget_file_name(attr_name:Optional[str]=None)->Optional[str]:
107108
returnattr_name
108109

109110

110111
classImageAttribute(FileAttribute):
111-
defget_file_name(self,attr_name:Optional[str]=None)->str:
112+
@staticmethod
113+
defget_file_name(attr_name:Optional[str]=None)->str:
112114
returnf"{attr_name}.png"ifattr_nameelse"image.png"

‎gitlab/v4/cli.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,14 @@ def get_dict(
377377

378378

379379
classJSONPrinter:
380-
defdisplay(self,d:Union[str,Dict[str,Any]],**kwargs:Any)->None:
380+
@staticmethod
381+
defdisplay(d:Union[str,Dict[str,Any]],**kwargs:Any)->None:
381382
importjson# noqa
382383

383384
print(json.dumps(d))
384385

386+
@staticmethod
385387
defdisplay_list(
386-
self,
387388
data:List[Union[str,gitlab.base.RESTObject]],
388389
fields:List[str],
389390
**kwargs:Any,
@@ -394,7 +395,8 @@ def display_list(
394395

395396

396397
classYAMLPrinter:
397-
defdisplay(self,d:Union[str,Dict[str,Any]],**kwargs:Any)->None:
398+
@staticmethod
399+
defdisplay(d:Union[str,Dict[str,Any]],**kwargs:Any)->None:
398400
try:
399401
importyaml# noqa
400402

@@ -406,8 +408,8 @@ def display(self, d: Union[str, Dict[str, Any]], **kwargs: Any) -> None:
406408
"to use the yaml output feature"
407409
)
408410

411+
@staticmethod
409412
defdisplay_list(
410-
self,
411413
data:List[Union[str,gitlab.base.RESTObject]],
412414
fields:List[str],
413415
**kwargs:Any,

‎gitlab/v4/objects/files.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
classProjectFile(SaveMixin,ObjectDeleteMixin,RESTObject):
2727
_id_attr="file_path"
2828
_repr_attr="file_path"
29+
branch:str
30+
commit_message:str
2931
file_path:str
3032
manager:"ProjectFileManager"
3133

‎gitlab/v4/objects/ldap.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,4 @@ def list(self, **kwargs: Any) -> Union[List[LDAPGroup], RESTObjectList]:
4949
obj=self.gitlab.http_list(path,**data)
5050
ifisinstance(obj,list):
5151
return [self._obj_cls(self,item)foriteminobj]
52-
else:
53-
returnRESTObjectList(self,self._obj_cls,obj)
52+
returnRESTObjectList(self,self._obj_cls,obj)

‎gitlab/v4/objects/merge_request_approvals.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ class ProjectMergeRequestApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject):
168168
_id_attr="approval_rule_id"
169169
_repr_attr="approval_rule"
170170
id:int
171+
approval_rule_id:int
172+
merge_request_iid:int
171173

172174
@exc.on_http_error(exc.GitlabUpdateError)
173175
defsave(self,**kwargs:Any)->None:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp