2323import requests .utils
2424from requests_toolbelt .multipart .encoder import MultipartEncoder # type: ignore
2525
26- import gitlab .config
27- import gitlab .const
28- import gitlab .exceptions
29- from gitlab import utils
26+ from .import config as gl_config
27+ from .import const ,exceptions ,utils
3028
3129REDIRECT_MSG = (
3230"python-gitlab detected a {status_code} ({reason!r}) redirection. You must update "
@@ -72,7 +70,7 @@ def __init__(
7270per_page :Optional [int ]= None ,
7371pagination :Optional [str ]= None ,
7472order_by :Optional [str ]= None ,
75- user_agent :str = gitlab . const .USER_AGENT ,
73+ user_agent :str = const .USER_AGENT ,
7674retry_transient_errors :bool = False ,
7775 )-> None :
7876
@@ -109,9 +107,9 @@ def __init__(
109107raise ModuleNotFoundError (name = f"gitlab.v{ self ._api_version } .objects" )
110108# NOTE: We must delay import of gitlab.v4.objects until now or
111109# otherwise it will cause circular import errors
112- import gitlab .v4 . objects
110+ from .v4 import objects as v4_objects
113111
114- objects = gitlab . v4 . objects
112+ objects = v4_objects
115113self ._objects = objects
116114
117115self .broadcastmessages = objects .BroadcastMessageManager (self )
@@ -234,7 +232,7 @@ def from_config(
234232 Raises:
235233 gitlab.config.GitlabDataError: If the configuration is not correct.
236234 """
237- config = gitlab . config .GitlabConfigParser (
235+ config = gl_config .GitlabConfigParser (
238236gitlab_id = gitlab_id ,config_files = config_files
239237 )
240238return cls (
@@ -287,7 +285,7 @@ def version(self) -> Tuple[str, str]:
287285
288286return cast (str ,self ._server_version ),cast (str ,self ._server_revision )
289287
290- @gitlab . exceptions .on_http_error (gitlab . exceptions .GitlabVerifyError )
288+ @exceptions .on_http_error (exceptions .GitlabVerifyError )
291289def lint (self ,content :str ,** kwargs :Any )-> Tuple [bool ,List [str ]]:
292290"""Validate a gitlab CI configuration.
293291
@@ -308,7 +306,7 @@ def lint(self, content: str, **kwargs: Any) -> Tuple[bool, List[str]]:
308306assert not isinstance (data ,requests .Response )
309307return (data ["status" ]== "valid" ,data ["errors" ])
310308
311- @gitlab . exceptions .on_http_error (gitlab . exceptions .GitlabMarkdownError )
309+ @exceptions .on_http_error (exceptions .GitlabMarkdownError )
312310def markdown (
313311self ,text :str ,gfm :bool = False ,project :Optional [str ]= None ,** kwargs :Any
314312 )-> str :
@@ -335,7 +333,7 @@ def markdown(
335333assert not isinstance (data ,requests .Response )
336334return data ["html" ]
337335
338- @gitlab . exceptions .on_http_error (gitlab . exceptions .GitlabLicenseError )
336+ @exceptions .on_http_error (exceptions .GitlabLicenseError )
339337def get_license (self ,** kwargs :Any )-> Dict [str ,Any ]:
340338"""Retrieve information about the current license.
341339
@@ -354,7 +352,7 @@ def get_license(self, **kwargs: Any) -> Dict[str, Any]:
354352return result
355353return {}
356354
357- @gitlab . exceptions .on_http_error (gitlab . exceptions .GitlabLicenseError )
355+ @exceptions .on_http_error (exceptions .GitlabLicenseError )
358356def set_license (self ,license :str ,** kwargs :Any )-> Dict [str ,Any ]:
359357"""Add a new license.
360358
@@ -445,7 +443,7 @@ def _get_base_url(self, url: Optional[str] = None) -> str:
445443 The base URL
446444 """
447445if not url :
448- return gitlab . const .DEFAULT_URL
446+ return const .DEFAULT_URL
449447
450448return url .rstrip ("/" )
451449
@@ -479,7 +477,7 @@ def _check_redirects(self, result: requests.Response) -> None:
479477if item .request .method == "GET" :
480478continue
481479target = item .headers .get ("location" )
482- raise gitlab . exceptions .RedirectError (
480+ raise exceptions .RedirectError (
483481REDIRECT_MSG .format (
484482status_code = item .status_code ,
485483reason = item .reason ,
@@ -639,13 +637,13 @@ def http_request(
639637pass
640638
641639if result .status_code == 401 :
642- raise gitlab . exceptions .GitlabAuthenticationError (
640+ raise exceptions .GitlabAuthenticationError (
643641response_code = result .status_code ,
644642error_message = error_message ,
645643response_body = result .content ,
646644 )
647645
648- raise gitlab . exceptions .GitlabHttpError (
646+ raise exceptions .GitlabHttpError (
649647response_code = result .status_code ,
650648error_message = error_message ,
651649response_body = result .content ,
@@ -691,7 +689,7 @@ def http_get(
691689try :
692690return result .json ()
693691except Exception as e :
694- raise gitlab . exceptions .GitlabParsingError (
692+ raise exceptions .GitlabParsingError (
695693error_message = "Failed to parse the server message"
696694 )from e
697695else :
@@ -788,7 +786,7 @@ def http_post(
788786if result .headers .get ("Content-Type" ,None )== "application/json" :
789787return result .json ()
790788except Exception as e :
791- raise gitlab . exceptions .GitlabParsingError (
789+ raise exceptions .GitlabParsingError (
792790error_message = "Failed to parse the server message"
793791 )from e
794792return result
@@ -836,7 +834,7 @@ def http_put(
836834try :
837835return result .json ()
838836except Exception as e :
839- raise gitlab . exceptions .GitlabParsingError (
837+ raise exceptions .GitlabParsingError (
840838error_message = "Failed to parse the server message"
841839 )from e
842840
@@ -856,7 +854,7 @@ def http_delete(self, path: str, **kwargs: Any) -> requests.Response:
856854 """
857855return self .http_request ("delete" ,path ,** kwargs )
858856
859- @gitlab . exceptions .on_http_error (gitlab . exceptions .GitlabSearchError )
857+ @exceptions .on_http_error (exceptions .GitlabSearchError )
860858def search (
861859self ,scope :str ,search :str ,** kwargs :Any
862860 )-> Union ["GitlabList" ,List [Dict [str ,Any ]]]:
@@ -932,7 +930,7 @@ def _query(
932930try :
933931self ._data :List [Dict [str ,Any ]]= result .json ()
934932except Exception as e :
935- raise gitlab . exceptions .GitlabParsingError (
933+ raise exceptions .GitlabParsingError (
936934error_message = "Failed to parse the server message"
937935 )from e
938936