| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4abcd17 commit e4a1f6e
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,10 +17,8 @@ | |||
| 17 | 17 | """Wrapper for the GitLab API.""" | |
| 18 | 18 | ||
| 19 | 19 | import warnings | |
| 20 | - from typing import Any | ||
| 21 | 20 | ||
| 22 | 21 | import gitlab.config # noqa: F401 | |
| 23 | - from gitlab import utils as _utils | ||
| 24 | 22 | from gitlab._version import ( # noqa: F401 | |
| 25 | 23 | __author__, | |
| 26 | 24 | __copyright__, | |
@@ -35,24 +33,6 @@ | |||
| 35 | 33 | warnings.filterwarnings("default", category=DeprecationWarning, module="^gitlab") | |
| 36 | 34 | ||
| 37 | 35 | ||
| 38 | - # NOTE(jlvillal): We are deprecating access to the gitlab.const values which | ||
| 39 | - # were previously imported into this namespace by the | ||
| 40 | - # 'from gitlab.const import *' statement. | ||
| 41 | - def __getattr__(name: str) -> Any: | ||
| 42 | - # Deprecate direct access to constants without namespace | ||
| 43 | - if name in gitlab.const._DEPRECATED: | ||
| 44 | - _utils.warn( | ||
| 45 | - message=( | ||
| 46 | - f"\nDirect access to constants as 'gitlab.{name}' is deprecated and " | ||
| 47 | - f"will be removed in a future major python-gitlab release. Please " | ||
| 48 | - f"see the usage of constants in the 'gitlab.const' module instead." | ||
| 49 | - ), | ||
| 50 | - category=DeprecationWarning, | ||
| 51 | - ) | ||
| 52 | - return getattr(gitlab.const, name) | ||
| 53 | - raise AttributeError(f"module {__name__} has no attribute {name}") | ||
| 54 | - | ||
| 55 | - | ||
| 56 | 36 | __all__ = [ | |
| 57 | 37 | "__author__", | |
| 58 | 38 | "__copyright__", | |
@@ -63,5 +43,4 @@ def __getattr__(name: str) -> Any: | |||
| 63 | 43 | "Gitlab", | |
| 64 | 44 | "GitlabList", | |
| 65 | 45 | ] | |
| 66 | - __all__.extend(gitlab.const._DEPRECATED) | ||
| 67 | 46 | __all__.extend(gitlab.exceptions.__all__) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,42 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | 3 | from gitlab._version import __title__, __version__ | |
| 4 | 4 | ||
| 5 | - # NOTE(jlvillal): '_DEPRECATED' only affects users accessing constants via the | ||
| 6 | - # top-level gitlab.* namespace. See 'gitlab/__init__.py:__getattr__()' for the | ||
| 7 | - # consumer of '_DEPRECATED' For example 'x = gitlab.NO_ACCESS'. We want users | ||
| 8 | - # to instead use constants by doing code like: gitlab.const.NO_ACCESS. | ||
| 9 | - _DEPRECATED = [ | ||
| 10 | - "ADMIN_ACCESS", | ||
| 11 | - "DEFAULT_URL", | ||
| 12 | - "DEVELOPER_ACCESS", | ||
| 13 | - "GUEST_ACCESS", | ||
| 14 | - "MAINTAINER_ACCESS", | ||
| 15 | - "MINIMAL_ACCESS", | ||
| 16 | - "NO_ACCESS", | ||
| 17 | - "NOTIFICATION_LEVEL_CUSTOM", | ||
| 18 | - "NOTIFICATION_LEVEL_DISABLED", | ||
| 19 | - "NOTIFICATION_LEVEL_GLOBAL", | ||
| 20 | - "NOTIFICATION_LEVEL_MENTION", | ||
| 21 | - "NOTIFICATION_LEVEL_PARTICIPATING", | ||
| 22 | - "NOTIFICATION_LEVEL_WATCH", | ||
| 23 | - "OWNER_ACCESS", | ||
| 24 | - "REPORTER_ACCESS", | ||
| 25 | - "SEARCH_SCOPE_BLOBS", | ||
| 26 | - "SEARCH_SCOPE_COMMITS", | ||
| 27 | - "SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES", | ||
| 28 | - "SEARCH_SCOPE_ISSUES", | ||
| 29 | - "SEARCH_SCOPE_MERGE_REQUESTS", | ||
| 30 | - "SEARCH_SCOPE_MILESTONES", | ||
| 31 | - "SEARCH_SCOPE_PROJECT_NOTES", | ||
| 32 | - "SEARCH_SCOPE_PROJECTS", | ||
| 33 | - "SEARCH_SCOPE_USERS", | ||
| 34 | - "SEARCH_SCOPE_WIKI_BLOBS", | ||
| 35 | - "USER_AGENT", | ||
| 36 | - "VISIBILITY_INTERNAL", | ||
| 37 | - "VISIBILITY_PRIVATE", | ||
| 38 | - "VISIBILITY_PUBLIC", | ||
| 39 | - ] | ||
| 40 | - | ||
| 41 | 5 | ||
| 42 | 6 | class GitlabEnum(str, Enum): | |
| 43 | 7 | """An enum mixed in with str to make it JSON-serializable.""" | |
@@ -138,5 +102,33 @@ class SearchScope(GitlabEnum): | |||
| 138 | 102 | "Visibility", | |
| 139 | 103 | "NotificationLevel", | |
| 140 | 104 | "SearchScope", | |
| 105 | + "ADMIN_ACCESS", | ||
| 106 | + "DEFAULT_URL", | ||
| 107 | + "DEVELOPER_ACCESS", | ||
| 108 | + "GUEST_ACCESS", | ||
| 109 | + "MAINTAINER_ACCESS", | ||
| 110 | + "MINIMAL_ACCESS", | ||
| 111 | + "NO_ACCESS", | ||
| 112 | + "NOTIFICATION_LEVEL_CUSTOM", | ||
| 113 | + "NOTIFICATION_LEVEL_DISABLED", | ||
| 114 | + "NOTIFICATION_LEVEL_GLOBAL", | ||
| 115 | + "NOTIFICATION_LEVEL_MENTION", | ||
| 116 | + "NOTIFICATION_LEVEL_PARTICIPATING", | ||
| 117 | + "NOTIFICATION_LEVEL_WATCH", | ||
| 118 | + "OWNER_ACCESS", | ||
| 119 | + "REPORTER_ACCESS", | ||
| 120 | + "SEARCH_SCOPE_BLOBS", | ||
| 121 | + "SEARCH_SCOPE_COMMITS", | ||
| 122 | + "SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES", | ||
| 123 | + "SEARCH_SCOPE_ISSUES", | ||
| 124 | + "SEARCH_SCOPE_MERGE_REQUESTS", | ||
| 125 | + "SEARCH_SCOPE_MILESTONES", | ||
| 126 | + "SEARCH_SCOPE_PROJECT_NOTES", | ||
| 127 | + "SEARCH_SCOPE_PROJECTS", | ||
| 128 | + "SEARCH_SCOPE_USERS", | ||
| 129 | + "SEARCH_SCOPE_WIKI_BLOBS", | ||
| 130 | + "USER_AGENT", | ||
| 131 | + "VISIBILITY_INTERNAL", | ||
| 132 | + "VISIBILITY_PRIVATE", | ||
| 133 | + "VISIBILITY_PUBLIC", | ||
| 141 | 134 | ] | |
| 142 | - __all__.extend(_DEPRECATED) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -342,4 +342,77 @@ def wrapped_f(*args: Any, **kwargs: Any) -> Any: | |||
| 342 | 342 | return wrap | |
| 343 | 343 | ||
| 344 | 344 | ||
| 345 | - __all__ = [name for name in dir() if name.endswith("Error")] | ||
| 345 | + # Export manually to keep mypy happy | ||
| 346 | + __all__ = [ | ||
| 347 | + "GitlabActivateError", | ||
| 348 | + "GitlabAttachFileError", | ||
| 349 | + "GitlabAuthenticationError", | ||
| 350 | + "GitlabBanError", | ||
| 351 | + "GitlabBlockError", | ||
| 352 | + "GitlabBuildCancelError", | ||
| 353 | + "GitlabBuildEraseError", | ||
| 354 | + "GitlabBuildPlayError", | ||
| 355 | + "GitlabBuildRetryError", | ||
| 356 | + "GitlabCancelError", | ||
| 357 | + "GitlabCherryPickError", | ||
| 358 | + "GitlabCiLintError", | ||
| 359 | + "GitlabConnectionError", | ||
| 360 | + "GitlabCreateError", | ||
| 361 | + "GitlabDeactivateError", | ||
| 362 | + "GitlabDeleteError", | ||
| 363 | + "GitlabDeploymentApprovalError", | ||
| 364 | + "GitlabError", | ||
| 365 | + "GitlabFollowError", | ||
| 366 | + "GitlabGetError", | ||
| 367 | + "GitlabGroupTransferError", | ||
| 368 | + "GitlabHeadError", | ||
| 369 | + "GitlabHousekeepingError", | ||
| 370 | + "GitlabHttpError", | ||
| 371 | + "GitlabImportError", | ||
| 372 | + "GitlabInvitationError", | ||
| 373 | + "GitlabJobCancelError", | ||
| 374 | + "GitlabJobEraseError", | ||
| 375 | + "GitlabJobPlayError", | ||
| 376 | + "GitlabJobRetryError", | ||
| 377 | + "GitlabLicenseError", | ||
| 378 | + "GitlabListError", | ||
| 379 | + "GitlabMRApprovalError", | ||
| 380 | + "GitlabMRClosedError", | ||
| 381 | + "GitlabMRForbiddenError", | ||
| 382 | + "GitlabMROnBuildSuccessError", | ||
| 383 | + "GitlabMRRebaseError", | ||
| 384 | + "GitlabMRResetApprovalError", | ||
| 385 | + "GitlabMarkdownError", | ||
| 386 | + "GitlabOperationError", | ||
| 387 | + "GitlabOwnershipError", | ||
| 388 | + "GitlabParsingError", | ||
| 389 | + "GitlabPipelineCancelError", | ||
| 390 | + "GitlabPipelinePlayError", | ||
| 391 | + "GitlabPipelineRetryError", | ||
| 392 | + "GitlabProjectDeployKeyError", | ||
| 393 | + "GitlabPromoteError", | ||
| 394 | + "GitlabProtectError", | ||
| 395 | + "GitlabRenderError", | ||
| 396 | + "GitlabRepairError", | ||
| 397 | + "GitlabRestoreError", | ||
| 398 | + "GitlabRetryError", | ||
| 399 | + "GitlabRevertError", | ||
| 400 | + "GitlabSearchError", | ||
| 401 | + "GitlabSetError", | ||
| 402 | + "GitlabStopError", | ||
| 403 | + "GitlabSubscribeError", | ||
| 404 | + "GitlabTimeTrackingError", | ||
| 405 | + "GitlabTodoError", | ||
| 406 | + "GitlabTopicMergeError", | ||
| 407 | + "GitlabTransferProjectError", | ||
| 408 | + "GitlabUnbanError", | ||
| 409 | + "GitlabUnblockError", | ||
| 410 | + "GitlabUnfollowError", | ||
| 411 | + "GitlabUnsubscribeError", | ||
| 412 | + "GitlabUpdateError", | ||
| 413 | + "GitlabUploadError", | ||
| 414 | + "GitlabUserApproveError", | ||
| 415 | + "GitlabUserRejectError", | ||
| 416 | + "GitlabVerifyError", | ||
| 417 | + "RedirectError", | ||
| 418 | + ] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,10 +6,21 @@ | |||
| 6 | 6 | import pkgutil | |
| 7 | 7 | from typing import Set | |
| 8 | 8 | ||
| 9 | + import gitlab.exceptions | ||
| 9 | 10 | import gitlab.v4.objects | |
| 10 | 11 | ||
| 11 | 12 | ||
| 12 | - def test_verify_v4_objects_imported() -> None: | ||
| 13 | + def test_all_exceptions_imports_are_exported() -> None: | ||
| 14 | + assert gitlab.exceptions.__all__ == sorted( | ||
| 15 | + [ | ||
| 16 | + name | ||
| 17 | + for name in dir(gitlab.exceptions) | ||
| 18 | + if name.endswith("Error") and not name.startswith("_") | ||
| 19 | + ] | ||
| 20 | + ) | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + def test_all_v4_objects_are_imported() -> None: | ||
| 13 | 24 | assert len(gitlab.v4.objects.__path__) == 1 | |
| 14 | 25 | ||
| 15 | 26 | init_files: Set[str] = set() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -336,16 +336,6 @@ def test_gitlab_user_agent(kwargs, expected_agent): | |||
| 336 | 336 | assert gl.headers["User-Agent"] == expected_agent | |
| 337 | 337 | ||
| 338 | 338 | ||
| 339 | - def test_gitlab_deprecated_global_const_warns(): | ||
| 340 | - with pytest.deprecated_call( | ||
| 341 | - match="'gitlab.NO_ACCESS' is deprecated.*constants in the 'gitlab.const'" | ||
| 342 | - ) as record: | ||
| 343 | - no_access = gitlab.NO_ACCESS | ||
| 344 | - | ||
| 345 | - assert len(record) == 1 | ||
| 346 | - assert no_access == 0 | ||
| 347 | - | ||
| 348 | - | ||
| 349 | 339 | def test_gitlab_enum_const_does_not_warn(recwarn): | |
| 350 | 340 | no_access = gitlab.const.AccessLevel.NO_ACCESS | |
| 351 | 341 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments