Skip to content

Commit d652133

Browse files
nejchJohnVillalovos
authored andcommitted
refactor: do not recommend plain gitlab.const constants
1 parent f185b17 commit d652133

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

gitlab/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def __getattr__(name: str) -> Any:
4343
if name in gitlab.const._DEPRECATED:
4444
_utils.warn(
4545
message=(
46-
f"\nDirect access to 'gitlab.{name}' is deprecated and will be "
47-
f"removed in a future major python-gitlab release. Please "
48-
f"use 'gitlab.const.{name}' instead."
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."
4949
),
5050
category=DeprecationWarning,
5151
)

gitlab/const.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
]
5757

5858

59+
class GitlabEnum(str, Enum):
60+
"""An enum mixed in with str to make it JSON-serializable."""
61+
62+
5963
# https://gitlab.com/gitlab-org/gitlab/-/blob/e97357824bedf007e75f8782259fe07435b64fbb/lib/gitlab/access.rb#L12-18
6064
class AccessLevel(IntEnum):
6165
NO_ACCESS: int = 0
@@ -69,13 +73,13 @@ class AccessLevel(IntEnum):
6973

7074

7175
# https://gitlab.com/gitlab-org/gitlab/-/blob/e97357824bedf007e75f8782259fe07435b64fbb/lib/gitlab/visibility_level.rb#L23-25
72-
class Visibility(Enum):
76+
class Visibility(GitlabEnum):
7377
PRIVATE: str = "private"
7478
INTERNAL: str = "internal"
7579
PUBLIC: str = "public"
7680

7781

78-
class NotificationLevel(Enum):
82+
class NotificationLevel(GitlabEnum):
7983
DISABLED: str = "disabled"
8084
PARTICIPATING: str = "participating"
8185
WATCH: str = "watch"
@@ -85,7 +89,7 @@ class NotificationLevel(Enum):
8589

8690

8791
# https://gitlab.com/gitlab-org/gitlab/-/blob/e97357824bedf007e75f8782259fe07435b64fbb/app/views/search/_category.html.haml#L10-37
88-
class SearchScope(Enum):
92+
class SearchScope(GitlabEnum):
8993
# all scopes (global, group and project)
9094
PROJECTS: str = "projects"
9195
ISSUES: str = "issues"

0 commit comments

Comments
 (0)