1717"""Wrapper for the GitLab API."""
1818
1919import 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
2121
2222import requests
2323import requests .utils
@@ -266,7 +266,8 @@ def lint(self, content: str, **kwargs: Any) -> Tuple[bool, List[str]]:
266266 """
267267 post_data = {"content" : content }
268268 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 )
270271 return (data ["status" ] == "valid" , data ["errors" ])
271272
272273 @gitlab .exceptions .on_http_error (gitlab .exceptions .GitlabMarkdownError )
@@ -294,7 +295,8 @@ def markdown(
294295 if project is not None :
295296 post_data ["project" ] = project
296297 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 )
298300 return data ["html" ]
299301
300302 @gitlab .exceptions .on_http_error (gitlab .exceptions .GitlabLicenseError )
@@ -333,7 +335,8 @@ def set_license(self, license: str, **kwargs: Any) -> Dict[str, Any]:
333335 """
334336 data = {"license" : license }
335337 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 )
337340 return result
338341
339342 def _set_auth_info (self ) -> None :
@@ -855,7 +858,8 @@ def _query(
855858 @property
856859 def current_page (self ) -> int :
857860 """The current page number."""
858- assert self ._current_page is not None
861+ if TYPE_CHECKING :
862+ assert self ._current_page is not None
859863 return int (self ._current_page )
860864
861865 @property
@@ -877,19 +881,22 @@ def next_page(self) -> Optional[int]:
877881 @property
878882 def per_page (self ) -> int :
879883 """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
881886 return int (self ._per_page )
882887
883888 @property
884889 def total_pages (self ) -> int :
885890 """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
887893 return int (self ._total_pages )
888894
889895 @property
890896 def total (self ) -> int :
891897 """The total number of items."""
892- assert self ._total is not None
898+ if TYPE_CHECKING :
899+ assert self ._total is not None
893900 return int (self ._total )
894901
895902 def __iter__ (self ) -> "GitlabList" :
0 commit comments