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

Commit8b75a77

Browse files
chore: add type-hints to multiple files in gitlab/v4/objects/
Add and/or check type-hints for the following files gitlab.v4.objects.access_requests gitlab.v4.objects.applications gitlab.v4.objects.broadcast_messages gitlab.v4.objects.deployments gitlab.v4.objects.keys gitlab.v4.objects.merge_trains gitlab.v4.objects.namespaces gitlab.v4.objects.pages gitlab.v4.objects.personal_access_tokens gitlab.v4.objects.project_access_tokens gitlab.v4.objects.tags gitlab.v4.objects.templates gitlab.v4.objects.triggersAdd a 'get' method with the correct type for Managers derived fromGetMixin.
1 parentf3688dc commit8b75a77

File tree

7 files changed

+51
-4
lines changed

7 files changed

+51
-4
lines changed

‎gitlab/v4/objects/broadcast_messages.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Union
2+
13
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
24
fromgitlab.mixinsimportCRUDMixin,ObjectDeleteMixin,SaveMixin
35

@@ -21,3 +23,8 @@ class BroadcastMessageManager(CRUDMixin, RESTManager):
2123
_update_attrs=RequiredOptional(
2224
optional=("message","starts_at","ends_at","color","font")
2325
)
26+
27+
defget(
28+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
29+
)->BroadcastMessage:
30+
returncast(BroadcastMessage,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/keys.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Optional,TYPE_CHECKING,Union
2+
13
fromgitlab.baseimportRESTManager,RESTObject
24
fromgitlab.mixinsimportGetMixin
35

@@ -15,12 +17,18 @@ class KeyManager(GetMixin, RESTManager):
1517
_path="/keys"
1618
_obj_cls=Key
1719

18-
defget(self,id=None,**kwargs):
20+
defget(
21+
self,id:Optional[Union[int,str]]=None,lazy:bool=False,**kwargs:Any
22+
)->Key:
1923
ifidisnotNone:
20-
returnsuper(KeyManager,self).get(id,**kwargs)
24+
returncast(Key,super(KeyManager,self).get(id,lazy=lazy,**kwargs))
2125

2226
if"fingerprint"notinkwargs:
2327
raiseAttributeError("Missing attribute: id or fingerprint")
2428

29+
ifTYPE_CHECKING:
30+
assertself.pathisnotNone
2531
server_data=self.gitlab.http_get(self.path,**kwargs)
26-
returnself._obj_cls(self,server_data)
32+
ifTYPE_CHECKING:
33+
assertisinstance(server_data,dict)
34+
returncast(Key,self._obj_cls(self,server_data))

‎gitlab/v4/objects/merge_trains.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ class ProjectMergeTrainManager(ListMixin, RESTManager):
1515
_path="/projects/%(project_id)s/merge_trains"
1616
_obj_cls=ProjectMergeTrain
1717
_from_parent_attrs= {"project_id":"id"}
18-
_list_filters="scope"
18+
_list_filters=("scope",)

‎gitlab/v4/objects/namespaces.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Union
2+
13
fromgitlab.baseimportRESTManager,RESTObject
24
fromgitlab.mixinsimportRetrieveMixin
35

@@ -15,3 +17,6 @@ class NamespaceManager(RetrieveMixin, RESTManager):
1517
_path="/namespaces"
1618
_obj_cls=Namespace
1719
_list_filters= ("search",)
20+
21+
defget(self,id:Union[str,int],lazy:bool=False,**kwargs:Any)->Namespace:
22+
returncast(Namespace,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/pages.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Union
2+
13
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
24
fromgitlab.mixinsimportCRUDMixin,ListMixin,ObjectDeleteMixin,SaveMixin
35

@@ -30,3 +32,8 @@ class ProjectPagesDomainManager(CRUDMixin, RESTManager):
3032
required=("domain",),optional=("certificate","key")
3133
)
3234
_update_attrs=RequiredOptional(optional=("certificate","key"))
35+
36+
defget(
37+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
38+
)->ProjectPagesDomain:
39+
returncast(ProjectPagesDomain,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/triggers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Union
2+
13
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
24
fromgitlab.mixinsimportCRUDMixin,ObjectDeleteMixin,SaveMixin
35

@@ -17,3 +19,8 @@ class ProjectTriggerManager(CRUDMixin, RESTManager):
1719
_from_parent_attrs= {"project_id":"id"}
1820
_create_attrs=RequiredOptional(required=("description",))
1921
_update_attrs=RequiredOptional(required=("description",))
22+
23+
defget(
24+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
25+
)->ProjectTrigger:
26+
returncast(ProjectTrigger,super().get(id=id,lazy=lazy,**kwargs))

‎pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,22 @@ ignore_errors = true
2323

2424
[[tool.mypy.overrides]]# Overrides to negate above patterns
2525
module = [
26+
"gitlab.v4.objects.access_requests",
27+
"gitlab.v4.objects.applications",
28+
"gitlab.v4.objects.broadcast_messages",
29+
"gitlab.v4.objects.deployments",
2630
"gitlab.v4.objects.groups",
31+
"gitlab.v4.objects.keys",
2732
"gitlab.v4.objects.merge_requests",
33+
"gitlab.v4.objects.merge_trains",
34+
"gitlab.v4.objects.namespaces",
35+
"gitlab.v4.objects.pages",
36+
"gitlab.v4.objects.personal_access_tokens",
37+
"gitlab.v4.objects.project_access_tokens",
2838
"gitlab.v4.objects.projects",
39+
"gitlab.v4.objects.tags",
40+
"gitlab.v4.objects.templates",
41+
"gitlab.v4.objects.triggers",
2942
"gitlab.v4.objects.users",
3043
]
3144
ignore_errors =false

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp