32
32
import requests
33
33
34
34
import gitlab
35
+ import gitlab .client as gl_client
35
36
from gitlab import base , cli
36
37
from gitlab import exceptions as exc
37
38
from gitlab import utils
@@ -138,7 +139,7 @@ def get(
138
139
return self ._obj_cls (self , {self ._obj_cls ._id_attr : id }, lazy = lazy )
139
140
server_data = self .gitlab .http_get (path , ** kwargs )
140
141
if TYPE_CHECKING :
141
- assert not isinstance (server_data , requests . Response )
142
+ assert isinstance (server_data , dict )
142
143
return self ._obj_cls (self , server_data , lazy = lazy )
143
144
144
145
@@ -170,7 +171,7 @@ def get(self, **kwargs: Any) -> base.RESTObject:
170
171
assert self .path is not None
171
172
server_data = self .gitlab .http_get (self .path , ** kwargs )
172
173
if TYPE_CHECKING :
173
- assert not isinstance (server_data , requests . Response )
174
+ assert isinstance (server_data , dict )
174
175
assert self ._obj_cls is not None
175
176
return self ._obj_cls (self , server_data )
176
177
@@ -204,7 +205,7 @@ def refresh(self, **kwargs: Any) -> None:
204
205
path = self .manager .path
205
206
server_data = self .manager .gitlab .http_get (path , ** kwargs )
206
207
if TYPE_CHECKING :
207
- assert not isinstance (server_data , requests . Response )
208
+ assert isinstance (server_data , dict )
208
209
self ._update_attrs (server_data )
209
210
210
211
@@ -309,7 +310,7 @@ def create(
309
310
path = kwargs .pop ("path" , self .path )
310
311
server_data = self .gitlab .http_post (path , post_data = data , files = files , ** kwargs )
311
312
if TYPE_CHECKING :
312
- assert not isinstance (server_data , requests . Response )
313
+ assert isinstance (server_data , dict )
313
314
assert self ._obj_cls is not None
314
315
return self ._obj_cls (self , server_data )
315
316
@@ -326,7 +327,7 @@ class UpdateMixin(_RestManagerBase):
326
327
327
328
def _get_update_method (
328
329
self ,
329
- ) -> Callable [..., Union [ Dict [ str , Any ], requests . Response ] ]:
330
+ ) -> Callable [..., gl_client . HttpResponseType ]:
330
331
"""Return the HTTP method to use.
331
332
332
333
Returns:
@@ -375,7 +376,7 @@ def update(
375
376
http_method = self ._get_update_method ()
376
377
result = http_method (path , post_data = new_data , files = files , ** kwargs )
377
378
if TYPE_CHECKING :
378
- assert not isinstance (result , requests . Response )
379
+ assert isinstance (result , dict )
379
380
return result
380
381
381
382
@@ -562,7 +563,7 @@ def user_agent_detail(self, **kwargs: Any) -> Dict[str, Any]:
562
563
path = f"{ self .manager .path } /{ self .encoded_id } /user_agent_detail"
563
564
result = self .manager .gitlab .http_get (path , ** kwargs )
564
565
if TYPE_CHECKING :
565
- assert not isinstance (result , requests . Response )
566
+ assert isinstance (result , dict )
566
567
return result
567
568
568
569
@@ -675,7 +676,7 @@ def subscribe(self, **kwargs: Any) -> None:
675
676
path = f"{ self .manager .path } /{ self .encoded_id } /subscribe"
676
677
server_data = self .manager .gitlab .http_post (path , ** kwargs )
677
678
if TYPE_CHECKING :
678
- assert not isinstance (server_data , requests . Response )
679
+ assert isinstance (server_data , dict )
679
680
self ._update_attrs (server_data )
680
681
681
682
@cli .register_custom_action (
@@ -695,7 +696,7 @@ def unsubscribe(self, **kwargs: Any) -> None:
695
696
path = f"{ self .manager .path } /{ self .encoded_id } /unsubscribe"
696
697
server_data = self .manager .gitlab .http_post (path , ** kwargs )
697
698
if TYPE_CHECKING :
698
- assert not isinstance (server_data , requests . Response )
699
+ assert isinstance (server_data , dict )
699
700
self ._update_attrs (server_data )
700
701
701
702
@@ -754,7 +755,7 @@ def time_stats(self, **kwargs: Any) -> Dict[str, Any]:
754
755
path = f"{ self .manager .path } /{ self .encoded_id } /time_stats"
755
756
result = self .manager .gitlab .http_get (path , ** kwargs )
756
757
if TYPE_CHECKING :
757
- assert not isinstance (result , requests . Response )
758
+ assert isinstance (result , dict )
758
759
return result
759
760
760
761
@cli .register_custom_action (("ProjectIssue" , "ProjectMergeRequest" ), ("duration" ,))
@@ -774,7 +775,7 @@ def time_estimate(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
774
775
data = {"duration" : duration }
775
776
result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
776
777
if TYPE_CHECKING :
777
- assert not isinstance (result , requests . Response )
778
+ assert isinstance (result , dict )
778
779
return result
779
780
780
781
@cli .register_custom_action (("ProjectIssue" , "ProjectMergeRequest" ))
@@ -792,7 +793,7 @@ def reset_time_estimate(self, **kwargs: Any) -> Dict[str, Any]:
792
793
path = f"{ self .manager .path } /{ self .encoded_id } /reset_time_estimate"
793
794
result = self .manager .gitlab .http_post (path , ** kwargs )
794
795
if TYPE_CHECKING :
795
- assert not isinstance (result , requests . Response )
796
+ assert isinstance (result , dict )
796
797
return result
797
798
798
799
@cli .register_custom_action (("ProjectIssue" , "ProjectMergeRequest" ), ("duration" ,))
@@ -812,7 +813,7 @@ def add_spent_time(self, duration: str, **kwargs: Any) -> Dict[str, Any]:
812
813
data = {"duration" : duration }
813
814
result = self .manager .gitlab .http_post (path , post_data = data , ** kwargs )
814
815
if TYPE_CHECKING :
815
- assert not isinstance (result , requests . Response )
816
+ assert isinstance (result , dict )
816
817
return result
817
818
818
819
@cli .register_custom_action (("ProjectIssue" , "ProjectMergeRequest" ))
@@ -830,7 +831,7 @@ def reset_spent_time(self, **kwargs: Any) -> Dict[str, Any]:
830
831
path = f"{ self .manager .path } /{ self .encoded_id } /reset_spent_time"
831
832
result = self .manager .gitlab .http_post (path , ** kwargs )
832
833
if TYPE_CHECKING :
833
- assert not isinstance (result , requests . Response )
834
+ assert isinstance (result , dict )
834
835
return result
835
836
836
837
@@ -864,7 +865,7 @@ def participants(self, **kwargs: Any) -> Dict[str, Any]:
864
865
path = f"{ self .manager .path } /{ self .encoded_id } /participants"
865
866
result = self .manager .gitlab .http_get (path , ** kwargs )
866
867
if TYPE_CHECKING :
867
- assert not isinstance (result , requests . Response )
868
+ assert isinstance (result , dict )
868
869
return result
869
870
870
871
@@ -892,7 +893,7 @@ def render(self, link_url: str, image_url: str, **kwargs: Any) -> Dict[str, Any]
892
893
data = {"link_url" : link_url , "image_url" : image_url }
893
894
result = self .gitlab .http_get (path , data , ** kwargs )
894
895
if TYPE_CHECKING :
895
- assert not isinstance (result , requests . Response )
896
+ assert isinstance (result , dict )
896
897
return result
897
898
898
899
@@ -907,7 +908,7 @@ class PromoteMixin(_RestObjectBase):
907
908
908
909
def _get_update_method (
909
910
self ,
910
- ) -> Callable [..., Union [ Dict [ str , Any ], requests . Response ] ]:
911
+ ) -> Callable [..., gl_client . HttpResponseType ]:
911
912
"""Return the HTTP method to use.
912
913
913
914
Returns:
@@ -939,5 +940,5 @@ def promote(self, **kwargs: Any) -> Dict[str, Any]:
939
940
http_method = self ._get_update_method ()
940
941
result = http_method (path , ** kwargs )
941
942
if TYPE_CHECKING :
942
- assert not isinstance (result , requests . Response )
943
+ assert isinstance (result , dict )
943
944
return result
0 commit comments