summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-03-06 18:57:08 +0100
committerGitHub <noreply@github.com>2021-03-06 18:57:08 +0100
commitc530f75a3f356e2fc9732c6a3688881e453115e7 (patch)
tree4781cb2c6575c338e5ad5d9e0c95660c680114f4
parentc7a06691a9fa15d0238e2b041ceee6121c5cf19e (diff)
parentb562458f063c6be970f58c733fe01ec786798549 (diff)
downloadgitlab-c530f75a3f356e2fc9732c6a3688881e453115e7.tar.gz
Merge pull request #1350 from JohnVillalovos/jlvillal/isinstance
chore: Put assert statements inside 'if TYPE_CHECKING:'
-rw-r--r--gitlab/client.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/gitlab/client.py b/gitlab/client.py
index 380d5b1..7927b3f 100644
--- a/gitlab/client.py
+++ b/gitlab/client.py
@@ -17,7 +17,7 @@
"""Wrapper for the GitLab API."""
import time
-from typing import cast, Any, Dict, List, Optional, Tuple, Union
+from typing import cast, Any, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
import requests
import requests.utils
@@ -266,7 +266,8 @@ class Gitlab(object):
"""
post_data = {"content": content}
data = self.http_post("/ci/lint", post_data=post_data, **kwargs)
- assert isinstance(data, dict)
+ if TYPE_CHECKING:
+ assert not isinstance(data, requests.Response)
return (data["status"] == "valid", data["errors"])
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabMarkdownError)
@@ -294,7 +295,8 @@ class Gitlab(object):
if project is not None:
post_data["project"] = project
data = self.http_post("/markdown", post_data=post_data, **kwargs)
- assert isinstance(data, dict)
+ if TYPE_CHECKING:
+ assert not isinstance(data, requests.Response)
return data["html"]
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabLicenseError)
@@ -333,7 +335,8 @@ class Gitlab(object):
"""
data = {"license": license}
result = self.http_post("/license", post_data=data, **kwargs)
- assert isinstance(result, dict)
+ if TYPE_CHECKING:
+ assert not isinstance(result, requests.Response)
return result
def _set_auth_info(self) -> None:
@@ -855,7 +858,8 @@ class GitlabList(object):
@property
def current_page(self) -> int:
"""The current page number."""
- assert self._current_page is not None
+ if TYPE_CHECKING:
+ assert self._current_page is not None
return int(self._current_page)
@property
@@ -877,19 +881,22 @@ class GitlabList(object):
@property
def per_page(self) -> int:
"""The number of items per page."""
- assert self._per_page is not None
+ if TYPE_CHECKING:
+ assert self._per_page is not None
return int(self._per_page)
@property
def total_pages(self) -> int:
"""The total number of pages."""
- assert self._total_pages is not None
+ if TYPE_CHECKING:
+ assert self._total_pages is not None
return int(self._total_pages)
@property
def total(self) -> int:
"""The total number of items."""
- assert self._total is not None
+ if TYPE_CHECKING:
+ assert self._total is not None
return int(self._total)
def __iter__(self) -> "GitlabList":