Skip to content

Commit

Permalink
Merge pull request #1318 from JohnVillalovos/jlvillal/testing
Browse files Browse the repository at this point in the history
chore: remove usage of 'from ... import *' in client.py
  • Loading branch information
nejch committed Feb 22, 2021
2 parents 8c58b07 + bf0c8c5 commit d9fdf1d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions gitlab/client.py
Expand Up @@ -22,9 +22,9 @@
import requests.utils

import gitlab.config
from gitlab.const import * # noqa
from gitlab.exceptions import * # noqa
from gitlab import utils # noqa
import gitlab.const
import gitlab.exceptions
from gitlab import utils
from requests_toolbelt.multipart.encoder import MultipartEncoder


Expand Down Expand Up @@ -69,7 +69,7 @@ def __init__(
per_page=None,
pagination=None,
order_by=None,
user_agent=USER_AGENT,
user_agent=gitlab.const.USER_AGENT,
):

self._api_version = str(api_version)
Expand Down Expand Up @@ -239,7 +239,7 @@ def version(self):

return self._server_version, self._server_revision

@on_http_error(GitlabVerifyError)
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabVerifyError)
def lint(self, content, **kwargs):
"""Validate a gitlab CI configuration.
Expand All @@ -259,7 +259,7 @@ def lint(self, content, **kwargs):
data = self.http_post("/ci/lint", post_data=post_data, **kwargs)
return (data["status"] == "valid", data["errors"])

@on_http_error(GitlabMarkdownError)
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabMarkdownError)
def markdown(self, text, gfm=False, project=None, **kwargs):
"""Render an arbitrary Markdown document.
Expand All @@ -284,7 +284,7 @@ def markdown(self, text, gfm=False, project=None, **kwargs):
data = self.http_post("/markdown", post_data=post_data, **kwargs)
return data["html"]

@on_http_error(GitlabLicenseError)
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabLicenseError)
def get_license(self, **kwargs):
"""Retrieve information about the current license.
Expand All @@ -300,7 +300,7 @@ def get_license(self, **kwargs):
"""
return self.http_get("/license", **kwargs)

@on_http_error(GitlabLicenseError)
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabLicenseError)
def set_license(self, license, **kwargs):
"""Add a new license.
Expand Down Expand Up @@ -438,7 +438,7 @@ def _check_redirects(self, result):
# Did we end-up with an https:// URL?
location = item.headers.get("Location", None)
if location and location.startswith("https://"):
raise RedirectError(REDIRECT_MSG)
raise gitlab.exceptions.RedirectError(REDIRECT_MSG)

def http_request(
self,
Expand Down Expand Up @@ -559,13 +559,13 @@ def http_request(
pass

if result.status_code == 401:
raise GitlabAuthenticationError(
raise gitlab.exceptions.GitlabAuthenticationError(
response_code=result.status_code,
error_message=error_message,
response_body=result.content,
)

raise GitlabHttpError(
raise gitlab.exceptions.GitlabHttpError(
response_code=result.status_code,
error_message=error_message,
response_body=result.content,
Expand Down Expand Up @@ -604,7 +604,7 @@ def http_get(self, path, query_data=None, streamed=False, raw=False, **kwargs):
try:
return result.json()
except Exception as e:
raise GitlabParsingError(
raise gitlab.exceptions.GitlabParsingError(
error_message="Failed to parse the server message"
) from e
else:
Expand Down Expand Up @@ -686,7 +686,7 @@ def http_post(self, path, query_data=None, post_data=None, files=None, **kwargs)
if result.headers.get("Content-Type", None) == "application/json":
return result.json()
except Exception as e:
raise GitlabParsingError(
raise gitlab.exceptions.GitlabParsingError(
error_message="Failed to parse the server message"
) from e
return result
Expand Down Expand Up @@ -724,7 +724,7 @@ def http_put(self, path, query_data=None, post_data=None, files=None, **kwargs):
try:
return result.json()
except Exception as e:
raise GitlabParsingError(
raise gitlab.exceptions.GitlabParsingError(
error_message="Failed to parse the server message"
) from e

Expand All @@ -744,7 +744,7 @@ def http_delete(self, path, **kwargs):
"""
return self.http_request("delete", path, **kwargs)

@on_http_error(GitlabSearchError)
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabSearchError)
def search(self, scope, search, **kwargs):
"""Search GitLab resources matching the provided string.'
Expand Down Expand Up @@ -804,7 +804,7 @@ def _query(self, url, query_data=None, **kwargs):
try:
self._data = result.json()
except Exception as e:
raise GitlabParsingError(
raise gitlab.exceptions.GitlabParsingError(
error_message="Failed to parse the server message"
) from e

Expand Down

0 comments on commit d9fdf1d

Please sign in to comment.