Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita9cf620

Browse files
chore: convert to using relative imports
Switch to using relative imports to ensure that we are importing fromwithin our library.Also use the form: from foo import bar as barWhen we want to signify that we want the import to be re-exported.https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-no-implicit-reexport
1 parent2708f91 commita9cf620

File tree

66 files changed

+231
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+231
-248
lines changed

‎gitlab/__init__.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
importwarnings
2020
fromtypingimportAny
2121

22-
importgitlab.config# noqa: F401
23-
fromgitlab.__version__import (# noqa: F401
24-
__author__,
25-
__copyright__,
26-
__email__,
27-
__license__,
28-
__title__,
29-
__version__,
30-
)
31-
fromgitlab.clientimportGitlab,GitlabList# noqa: F401
32-
fromgitlab.exceptionsimport*# noqa: F401,F403
22+
from .importconfigasconfig# noqa: F401
23+
from .importconstasconst
24+
from .importexceptionsasexceptions# noqa: F401
25+
from .__version__import__author__as__author__# noqa: F401
26+
from .__version__import__copyright__as__copyright__# noqa: F401
27+
from .__version__import__email__as__email__# noqa: F401
28+
from .__version__import__license__as__license__# noqa: F401
29+
from .__version__import__title__as__title__# noqa: F401
30+
from .__version__import__version__as__version__# noqa: F401
31+
from .clientimportGitlabasGitlab# noqa: F401
32+
from .clientimportGitlabListasGitlabList# noqa: F401
33+
from .exceptionsimport*# noqa: F401,F403
3334

3435
warnings.filterwarnings("default",category=DeprecationWarning,module="^gitlab")
3536

@@ -39,12 +40,12 @@
3940
# 'from gitlab.const import *' statement.
4041
def__getattr__(name:str)->Any:
4142
# Deprecate direct access to constants without namespace
42-
ifnameingitlab.const._DEPRECATED:
43+
ifnameinconst._DEPRECATED:
4344
warnings.warn(
4445
f"\nDirect access to 'gitlab.{name}' is deprecated and will be "
4546
f"removed in a future major python-gitlab release. Please "
4647
f"use 'gitlab.const.{name}' instead.",
4748
DeprecationWarning,
4849
)
49-
returngetattr(gitlab.const,name)
50+
returngetattr(const,name)
5051
raiseAttributeError(f"module{__name__} has no attribute{name}")

‎gitlab/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
importgitlab.cli
1+
from .importcli
22

33
if__name__=="__main__":
4-
gitlab.cli.main()
4+
cli.main()

‎gitlab/base.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
fromtypesimportModuleType
2121
fromtypingimportAny,Dict,Iterable,NamedTuple,Optional,Tuple,Type
2222

23-
importgitlab
24-
fromgitlabimporttypesasg_types
25-
fromgitlab.exceptionsimportGitlabParsingError
26-
23+
from .__version__import__version__
2724
from .clientimportGitlab,GitlabList
25+
from .exceptionsimportGitlabParsingError
26+
from .typesimportGitlabAttribute
2827

2928
__all__= [
3029
"RequiredOptional",
@@ -35,7 +34,7 @@
3534

3635

3736
_URL_ATTRIBUTE_ERROR= (
38-
f"https://python-gitlab.readthedocs.io/en/{gitlab.__version__}/"
37+
f"https://python-gitlab.readthedocs.io/en/{__version__}/"
3938
f"faq.html#attribute-error-list"
4039
)
4140

@@ -317,7 +316,7 @@ class RESTManager(object):
317316
_path:Optional[str]=None
318317
_obj_cls:Optional[Type[RESTObject]]=None
319318
_from_parent_attrs:Dict[str,Any]= {}
320-
_types:Dict[str,Type[g_types.GitlabAttribute]]= {}
319+
_types:Dict[str,Type[GitlabAttribute]]= {}
321320

322321
_computed_path:Optional[str]
323322
_parent:Optional[RESTObject]

‎gitlab/client.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
importrequests.utils
2424
fromrequests_toolbelt.multipart.encoderimportMultipartEncoder# type: ignore
2525

26-
importgitlab.config
27-
importgitlab.const
28-
importgitlab.exceptions
29-
fromgitlabimportutils
26+
from .importconfigasgl_config
27+
from .importconst,exceptions,utils
3028

3129
REDIRECT_MSG= (
3230
"python-gitlab detected a {status_code} ({reason!r}) redirection. You must update "
@@ -72,7 +70,7 @@ def __init__(
7270
per_page:Optional[int]=None,
7371
pagination:Optional[str]=None,
7472
order_by:Optional[str]=None,
75-
user_agent:str=gitlab.const.USER_AGENT,
73+
user_agent:str=const.USER_AGENT,
7674
retry_transient_errors:bool=False,
7775
)->None:
7876

@@ -109,9 +107,9 @@ def __init__(
109107
raiseModuleNotFoundError(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-
importgitlab.v4.objects
110+
from.v4importobjectsasv4_objects
113111

114-
objects=gitlab.v4.objects
112+
objects=v4_objects
115113
self._objects=objects
116114

117115
self.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(
238236
gitlab_id=gitlab_id,config_files=config_files
239237
)
240238
returncls(
@@ -287,7 +285,7 @@ def version(self) -> Tuple[str, str]:
287285

288286
returncast(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)
291289
deflint(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]]:
308306
assertnotisinstance(data,requests.Response)
309307
return (data["status"]=="valid",data["errors"])
310308

311-
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabMarkdownError)
309+
@exceptions.on_http_error(exceptions.GitlabMarkdownError)
312310
defmarkdown(
313311
self,text:str,gfm:bool=False,project:Optional[str]=None,**kwargs:Any
314312
)->str:
@@ -335,7 +333,7 @@ def markdown(
335333
assertnotisinstance(data,requests.Response)
336334
returndata["html"]
337335

338-
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabLicenseError)
336+
@exceptions.on_http_error(exceptions.GitlabLicenseError)
339337
defget_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]:
354352
returnresult
355353
return {}
356354

357-
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabLicenseError)
355+
@exceptions.on_http_error(exceptions.GitlabLicenseError)
358356
defset_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
"""
447445
ifnoturl:
448-
returngitlab.const.DEFAULT_URL
446+
returnconst.DEFAULT_URL
449447

450448
returnurl.rstrip("/")
451449

@@ -479,7 +477,7 @@ def _check_redirects(self, result: requests.Response) -> None:
479477
ifitem.request.method=="GET":
480478
continue
481479
target=item.headers.get("location")
482-
raisegitlab.exceptions.RedirectError(
480+
raiseexceptions.RedirectError(
483481
REDIRECT_MSG.format(
484482
status_code=item.status_code,
485483
reason=item.reason,
@@ -639,13 +637,13 @@ def http_request(
639637
pass
640638

641639
ifresult.status_code==401:
642-
raisegitlab.exceptions.GitlabAuthenticationError(
640+
raiseexceptions.GitlabAuthenticationError(
643641
response_code=result.status_code,
644642
error_message=error_message,
645643
response_body=result.content,
646644
)
647645

648-
raisegitlab.exceptions.GitlabHttpError(
646+
raiseexceptions.GitlabHttpError(
649647
response_code=result.status_code,
650648
error_message=error_message,
651649
response_body=result.content,
@@ -691,7 +689,7 @@ def http_get(
691689
try:
692690
returnresult.json()
693691
exceptExceptionase:
694-
raisegitlab.exceptions.GitlabParsingError(
692+
raiseexceptions.GitlabParsingError(
695693
error_message="Failed to parse the server message"
696694
)frome
697695
else:
@@ -788,7 +786,7 @@ def http_post(
788786
ifresult.headers.get("Content-Type",None)=="application/json":
789787
returnresult.json()
790788
exceptExceptionase:
791-
raisegitlab.exceptions.GitlabParsingError(
789+
raiseexceptions.GitlabParsingError(
792790
error_message="Failed to parse the server message"
793791
)frome
794792
returnresult
@@ -836,7 +834,7 @@ def http_put(
836834
try:
837835
returnresult.json()
838836
exceptExceptionase:
839-
raisegitlab.exceptions.GitlabParsingError(
837+
raiseexceptions.GitlabParsingError(
840838
error_message="Failed to parse the server message"
841839
)frome
842840

@@ -856,7 +854,7 @@ def http_delete(self, path: str, **kwargs: Any) -> requests.Response:
856854
"""
857855
returnself.http_request("delete",path,**kwargs)
858856

859-
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabSearchError)
857+
@exceptions.on_http_error(exceptions.GitlabSearchError)
860858
defsearch(
861859
self,scope:str,search:str,**kwargs:Any
862860
)->Union["GitlabList",List[Dict[str,Any]]]:
@@ -932,7 +930,7 @@ def _query(
932930
try:
933931
self._data:List[Dict[str,Any]]=result.json()
934932
exceptExceptionase:
935-
raisegitlab.exceptions.GitlabParsingError(
933+
raiseexceptions.GitlabParsingError(
936934
error_message="Failed to parse the server message"
937935
)frome
938936

‎gitlab/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# You should have received a copy of the GNU Lesser General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18-
fromgitlab.__version__import__title__,__version__
18+
from .__version__import__title__,__version__
1919

2020
# NOTE(jlvillal): '_DEPRECATED' only affects users accessing constants via the
2121
# top-level gitlab.* namespace. See 'gitlab/__init__.py:__getattr__()' for the

‎gitlab/v4/objects/access_requests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
fromgitlab.baseimportRESTManager,RESTObject
2-
fromgitlab.mixinsimport (
1+
from...baseimportRESTManager,RESTObject
2+
from...mixinsimport (
33
AccessRequestMixin,
44
CreateMixin,
55
DeleteMixin,

‎gitlab/v4/objects/appearance.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
fromtypingimportAny,cast,Dict,Optional,Union
22

3-
fromgitlabimportexceptionsasexc
4-
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
5-
fromgitlab.mixinsimportGetWithoutIdMixin,SaveMixin,UpdateMixin
3+
from...importexceptionsasexc
4+
from...baseimportRequiredOptional,RESTManager,RESTObject
5+
from...mixinsimportGetWithoutIdMixin,SaveMixin,UpdateMixin
66

77
__all__= [
88
"ApplicationAppearance",

‎gitlab/v4/objects/applications.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
2-
fromgitlab.mixinsimportCreateMixin,DeleteMixin,ListMixin,ObjectDeleteMixin
1+
from...baseimportRequiredOptional,RESTManager,RESTObject
2+
from...mixinsimportCreateMixin,DeleteMixin,ListMixin,ObjectDeleteMixin
33

44
__all__= [
55
"Application",

‎gitlab/v4/objects/audit_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"""
55
fromtypingimportAny,cast,Union
66

7-
fromgitlab.baseimportRESTManager,RESTObject
8-
fromgitlab.mixinsimportRetrieveMixin
7+
from...baseimportRESTManager,RESTObject
8+
from...mixinsimportRetrieveMixin
99

1010
__all__= [
1111
"AuditEvent",

‎gitlab/v4/objects/award_emojis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fromtypingimportAny,cast,Union
22

3-
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
4-
fromgitlab.mixinsimportNoUpdateMixin,ObjectDeleteMixin
3+
from...baseimportRequiredOptional,RESTManager,RESTObject
4+
from...mixinsimportNoUpdateMixin,ObjectDeleteMixin
55

66
__all__= [
77
"GroupEpicAwardEmoji",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp