Skip to content

Commit bf0c8c5

Browse files
chore: remove usage of 'from ... import *' in client.py
In gitlab/client.py remove usage of: * from gitlab.const import * * from gitlab.exceptions import * Change them to: * import gitlab.const * import gitlab.exceptions Update code to explicitly reference things in gitlab.const and gitlab.exceptions A flake8 run no longer lists any undefined variables. Before it listed possible undefined variables.
1 parent 8c58b07 commit bf0c8c5

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

gitlab/client.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import requests.utils
2323

2424
import gitlab.config
25-
from gitlab.const import * # noqa
26-
from gitlab.exceptions import * # noqa
27-
from gitlab import utils # noqa
25+
import gitlab.const
26+
import gitlab.exceptions
27+
from gitlab import utils
2828
from requests_toolbelt.multipart.encoder import MultipartEncoder
2929

3030

@@ -69,7 +69,7 @@ def __init__(
6969
per_page=None,
7070
pagination=None,
7171
order_by=None,
72-
user_agent=USER_AGENT,
72+
user_agent=gitlab.const.USER_AGENT,
7373
):
7474

7575
self._api_version = str(api_version)
@@ -239,7 +239,7 @@ def version(self):
239239

240240
return self._server_version, self._server_revision
241241

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

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

287-
@on_http_error(GitlabLicenseError)
287+
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabLicenseError)
288288
def get_license(self, **kwargs):
289289
"""Retrieve information about the current license.
290290
@@ -300,7 +300,7 @@ def get_license(self, **kwargs):
300300
"""
301301
return self.http_get("/license", **kwargs)
302302

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

443443
def http_request(
444444
self,
@@ -559,13 +559,13 @@ def http_request(
559559
pass
560560

561561
if result.status_code == 401:
562-
raise GitlabAuthenticationError(
562+
raise gitlab.exceptions.GitlabAuthenticationError(
563563
response_code=result.status_code,
564564
error_message=error_message,
565565
response_body=result.content,
566566
)
567567

568-
raise GitlabHttpError(
568+
raise gitlab.exceptions.GitlabHttpError(
569569
response_code=result.status_code,
570570
error_message=error_message,
571571
response_body=result.content,
@@ -604,7 +604,7 @@ def http_get(self, path, query_data=None, streamed=False, raw=False, **kwargs):
604604
try:
605605
return result.json()
606606
except Exception as e:
607-
raise GitlabParsingError(
607+
raise gitlab.exceptions.GitlabParsingError(
608608
error_message="Failed to parse the server message"
609609
) from e
610610
else:
@@ -686,7 +686,7 @@ def http_post(self, path, query_data=None, post_data=None, files=None, **kwargs)
686686
if result.headers.get("Content-Type", None) == "application/json":
687687
return result.json()
688688
except Exception as e:
689-
raise GitlabParsingError(
689+
raise gitlab.exceptions.GitlabParsingError(
690690
error_message="Failed to parse the server message"
691691
) from e
692692
return result
@@ -724,7 +724,7 @@ def http_put(self, path, query_data=None, post_data=None, files=None, **kwargs):
724724
try:
725725
return result.json()
726726
except Exception as e:
727-
raise GitlabParsingError(
727+
raise gitlab.exceptions.GitlabParsingError(
728728
error_message="Failed to parse the server message"
729729
) from e
730730

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

747-
@on_http_error(GitlabSearchError)
747+
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabSearchError)
748748
def search(self, scope, search, **kwargs):
749749
"""Search GitLab resources matching the provided string.'
750750
@@ -804,7 +804,7 @@ def _query(self, url, query_data=None, **kwargs):
804804
try:
805805
self._data = result.json()
806806
except Exception as e:
807-
raise GitlabParsingError(
807+
raise gitlab.exceptions.GitlabParsingError(
808808
error_message="Failed to parse the server message"
809809
) from e
810810

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy