1
+ from typing import Any ,cast ,Dict ,Optional ,TYPE_CHECKING ,Union
2
+
1
3
from gitlab import exceptions as exc
2
4
from gitlab import types
3
5
from gitlab .base import RequiredOptional ,RESTManager ,RESTObject
@@ -42,11 +44,19 @@ class GroupEpicManager(CRUDMixin, RESTManager):
42
44
)
43
45
_types = {"labels" :types .ListAttribute }
44
46
47
+ def get (
48
+ self ,id :Union [str ,int ],lazy :bool = False ,** kwargs :Any
49
+ )-> GroupEpic :
50
+ return cast (GroupEpic ,super ().get (id = id ,lazy = lazy ,** kwargs ))
51
+
45
52
46
53
class GroupEpicIssue (ObjectDeleteMixin ,SaveMixin ,RESTObject ):
47
54
_id_attr = "epic_issue_id"
55
+ # Define type for 'manager' here So mypy won't complain about
56
+ # 'self.manager.update()' call in the 'save' method.
57
+ manager :"GroupEpicIssueManager"
48
58
49
- def save (self ,** kwargs ) :
59
+ def save (self ,** kwargs : Any ) -> None :
50
60
"""Save the changes made to the object to the server.
51
61
52
62
The object is updated to match what the server returns.
@@ -78,7 +88,9 @@ class GroupEpicIssueManager(
78
88
_update_attrs = RequiredOptional (optional = ("move_before_id" ,"move_after_id" ))
79
89
80
90
@exc .on_http_error (exc .GitlabCreateError )
81
- def create (self ,data ,** kwargs ):
91
+ def create (
92
+ self ,data :Optional [Dict [str ,Any ]]= None ,** kwargs :Any
93
+ )-> GroupEpicIssue :
82
94
"""Create a new object.
83
95
84
96
Args:
@@ -94,9 +106,13 @@ def create(self, data, **kwargs):
94
106
RESTObject: A new instance of the manage object class build with
95
107
the data sent by the server
96
108
"""
109
+ if TYPE_CHECKING :
110
+ assert data is not None
97
111
CreateMixin ._check_missing_create_attrs (self ,data )
98
112
path = f"{ self .path } /{ data .pop ('issue_id' )} "
99
113
server_data = self .gitlab .http_post (path ,** kwargs )
114
+ if TYPE_CHECKING :
115
+ assert isinstance (server_data ,dict )
100
116
# The epic_issue_id attribute doesn't exist when creating the resource,
101
117
# but is used everywhere elese. Let's create it to be consistent client
102
118
# side