diff options
| author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-06-22 23:34:47 +0200 |
|---|---|---|
| committer | John Villalovos <john@sodarock.com> | 2022-06-27 16:36:23 -0700 |
| commit | d65213385a6f497c2595d3af3a41756919b9c9a1 (patch) | |
| tree | a736bd15d750b4dd300bdfb982923e3ec562f3aa | |
| parent | f185b17ff5aabedd32d3facd2a46ebf9069c9692 (diff) | |
| download | gitlab-d65213385a6f497c2595d3af3a41756919b9c9a1.tar.gz | |
refactor: do not recommend plain gitlab.const constants
| -rw-r--r-- | gitlab/__init__.py | 6 | ||||
| -rw-r--r-- | gitlab/const.py | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index c8fc975..190b513 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -43,9 +43,9 @@ def __getattr__(name: str) -> Any: if name in gitlab.const._DEPRECATED: _utils.warn( message=( - f"\nDirect access to 'gitlab.{name}' is deprecated and will be " - f"removed in a future major python-gitlab release. Please " - f"use 'gitlab.const.{name}' instead." + f"\nDirect access to constants as 'gitlab.{name}' is deprecated and " + f"will be removed in a future major python-gitlab release. Please " + f"see the usage of constants in the 'gitlab.const' module instead." ), category=DeprecationWarning, ) diff --git a/gitlab/const.py b/gitlab/const.py index 382590d..5108de2 100644 --- a/gitlab/const.py +++ b/gitlab/const.py @@ -56,6 +56,10 @@ _DEPRECATED = [ ] +class GitlabEnum(str, Enum): + """An enum mixed in with str to make it JSON-serializable.""" + + # https://gitlab.com/gitlab-org/gitlab/-/blob/e97357824bedf007e75f8782259fe07435b64fbb/lib/gitlab/access.rb#L12-18 class AccessLevel(IntEnum): NO_ACCESS: int = 0 @@ -69,13 +73,13 @@ class AccessLevel(IntEnum): # https://gitlab.com/gitlab-org/gitlab/-/blob/e97357824bedf007e75f8782259fe07435b64fbb/lib/gitlab/visibility_level.rb#L23-25 -class Visibility(Enum): +class Visibility(GitlabEnum): PRIVATE: str = "private" INTERNAL: str = "internal" PUBLIC: str = "public" -class NotificationLevel(Enum): +class NotificationLevel(GitlabEnum): DISABLED: str = "disabled" PARTICIPATING: str = "participating" WATCH: str = "watch" @@ -85,7 +89,7 @@ class NotificationLevel(Enum): # https://gitlab.com/gitlab-org/gitlab/-/blob/e97357824bedf007e75f8782259fe07435b64fbb/app/views/search/_category.html.haml#L10-37 -class SearchScope(Enum): +class SearchScope(GitlabEnum): # all scopes (global, group and project) PROJECTS: str = "projects" ISSUES: str = "issues" |
