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

Commitde73ea7

Browse files
authored
Merge pull request#1365 from JohnVillalovos/jlvillal/getattr
chore: make _types always present in RESTManager
2 parents48fc907 +924f83e commitde73ea7

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

‎gitlab/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
fromtypingimportAny,Dict,Optional,Type
2121

2222
from .clientimportGitlab,GitlabList
23+
fromgitlabimporttypesasg_types
2324

2425
__all__= [
2526
"RESTObject",
@@ -260,6 +261,7 @@ class RESTManager(object):
260261
_path:Optional[str]=None
261262
_obj_cls:Optional[Type[RESTObject]]=None
262263
_from_parent_attrs:Dict[str,Any]= {}
264+
_types:Dict[str,Type[g_types.GitlabAttribute]]= {}
263265

264266
_computed_path:Optional[str]
265267
_parent:Optional[RESTObject]

‎gitlab/mixins.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,8 @@ def list(self, **kwargs: Any) -> Union[base.RESTObjectList, List[base.RESTObject
226226
data.setdefault("order_by",self.gitlab.order_by)
227227

228228
# We get the attributes that need some special transformation
229-
types=getattr(self,"_types", {})
230-
iftypes:
231-
forattr_name,type_clsintypes.items():
229+
ifself._types:
230+
forattr_name,type_clsinself._types.items():
232231
ifattr_nameindata.keys():
233232
type_obj=type_cls(data[attr_name])
234233
data[attr_name]=type_obj.get_for_api()
@@ -311,17 +310,16 @@ def create(
311310
files= {}
312311

313312
# We get the attributes that need some special transformation
314-
types=getattr(self,"_types", {})
315-
iftypes:
313+
ifself._types:
316314
# Duplicate data to avoid messing with what the user sent us
317315
data=data.copy()
318-
forattr_name,type_clsintypes.items():
316+
forattr_name,type_clsinself._types.items():
319317
ifattr_nameindata.keys():
320318
type_obj=type_cls(data[attr_name])
321319

322320
# if the type if FileAttribute we need to pass the data as
323321
# file
324-
ifissubclass(type_cls,g_types.FileAttribute):
322+
ifisinstance(type_obj,g_types.FileAttribute):
325323
k=type_obj.get_file_name(attr_name)
326324
files[attr_name]= (k,data.pop(attr_name))
327325
else:
@@ -414,17 +412,16 @@ def update(
414412
files= {}
415413

416414
# We get the attributes that need some special transformation
417-
types=getattr(self,"_types", {})
418-
iftypes:
415+
ifself._types:
419416
# Duplicate data to avoid messing with what the user sent us
420417
new_data=new_data.copy()
421-
forattr_name,type_clsintypes.items():
418+
forattr_name,type_clsinself._types.items():
422419
ifattr_nameinnew_data.keys():
423420
type_obj=type_cls(new_data[attr_name])
424421

425422
# if the type if FileAttribute we need to pass the data as
426423
# file
427-
ifissubclass(type_cls,g_types.FileAttribute):
424+
ifisinstance(type_obj,g_types.FileAttribute):
428425
k=type_obj.get_file_name(attr_name)
429426
files[attr_name]= (k,new_data.pop(attr_name))
430427
else:

‎gitlab/v4/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ def __init__(self, gl, what, action, args):
4242
self.mgr_cls._path=self.mgr_cls._path%self.args
4343
self.mgr=self.mgr_cls(gl)
4444

45-
types=getattr(self.mgr_cls,"_types", {})
46-
iftypes:
47-
forattr_name,type_clsintypes.items():
45+
ifself.mgr_cls._types:
46+
forattr_name,type_clsinself.mgr_cls._types.items():
4847
ifattr_nameinself.args.keys():
4948
obj=type_cls()
5049
obj.set_from_cli(self.args[attr_name])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp