17
17
"""Wrapper for the GitLab API."""
18
18
19
19
import time
20
- from typing import cast , Any , Dict , List , Optional , Tuple , Union
20
+ from typing import cast , Any , Dict , List , Optional , Tuple , TYPE_CHECKING , Union
21
21
22
22
import requests
23
23
import requests .utils
@@ -266,7 +266,8 @@ def lint(self, content: str, **kwargs: Any) -> Tuple[bool, List[str]]:
266
266
"""
267
267
post_data = {"content" : content }
268
268
data = self .http_post ("/ci/lint" , post_data = post_data , ** kwargs )
269
- assert isinstance (data , dict )
269
+ if TYPE_CHECKING :
270
+ assert not isinstance (data , requests .Response )
270
271
return (data ["status" ] == "valid" , data ["errors" ])
271
272
272
273
@gitlab .exceptions .on_http_error (gitlab .exceptions .GitlabMarkdownError )
@@ -294,7 +295,8 @@ def markdown(
294
295
if project is not None :
295
296
post_data ["project" ] = project
296
297
data = self .http_post ("/markdown" , post_data = post_data , ** kwargs )
297
- assert isinstance (data , dict )
298
+ if TYPE_CHECKING :
299
+ assert not isinstance (data , requests .Response )
298
300
return data ["html" ]
299
301
300
302
@gitlab .exceptions .on_http_error (gitlab .exceptions .GitlabLicenseError )
@@ -333,7 +335,8 @@ def set_license(self, license: str, **kwargs: Any) -> Dict[str, Any]:
333
335
"""
334
336
data = {"license" : license }
335
337
result = self .http_post ("/license" , post_data = data , ** kwargs )
336
- assert isinstance (result , dict )
338
+ if TYPE_CHECKING :
339
+ assert not isinstance (result , requests .Response )
337
340
return result
338
341
339
342
def _set_auth_info (self ) -> None :
@@ -855,7 +858,8 @@ def _query(
855
858
@property
856
859
def current_page (self ) -> int :
857
860
"""The current page number."""
858
- assert self ._current_page is not None
861
+ if TYPE_CHECKING :
862
+ assert self ._current_page is not None
859
863
return int (self ._current_page )
860
864
861
865
@property
@@ -877,19 +881,22 @@ def next_page(self) -> Optional[int]:
877
881
@property
878
882
def per_page (self ) -> int :
879
883
"""The number of items per page."""
880
- assert self ._per_page is not None
884
+ if TYPE_CHECKING :
885
+ assert self ._per_page is not None
881
886
return int (self ._per_page )
882
887
883
888
@property
884
889
def total_pages (self ) -> int :
885
890
"""The total number of pages."""
886
- assert self ._total_pages is not None
891
+ if TYPE_CHECKING :
892
+ assert self ._total_pages is not None
887
893
return int (self ._total_pages )
888
894
889
895
@property
890
896
def total (self ) -> int :
891
897
"""The total number of items."""
892
- assert self ._total is not None
898
+ if TYPE_CHECKING :
899
+ assert self ._total is not None
893
900
return int (self ._total )
894
901
895
902
def __iter__ (self ) -> "GitlabList" :
0 commit comments