Skip to content

chore: remove usage of 'from ... import *' in client.py #1318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions gitlab/client.py
Original file line number Diff line number Diff line change
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