GeezerVison is showing github.com — refactor: do not recommend plain gitlab.const constants · python-gitlab/python-gitlab@d652133
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: gitlab/__init__.py +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,9 +43,9 @@ def __getattr__(name: str) -> Any: |
43 | 43 | if name in gitlab.const._DEPRECATED: |
44 | 44 | _utils.warn( |
45 | 45 | 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." |
49 | 49 | ), |
50 | 50 | category=DeprecationWarning, |
51 | 51 | ) |
|
Collapse file
Copy file name to clipboardExpand all lines: gitlab/const.py +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
56 | 56 | ] |
57 | 57 |
|
58 | 58 |
|
| 59 | +class GitlabEnum(str, Enum): |
| 60 | + """An enum mixed in with str to make it JSON-serializable.""" |
| 61 | + |
| 62 | + |
59 | 63 | # https://gitlab.com/gitlab-org/gitlab/-/blob/e97357824bedf007e75f8782259fe07435b64fbb/lib/gitlab/access.rb#L12-18 |
60 | 64 | class AccessLevel(IntEnum): |
61 | 65 | NO_ACCESS: int = 0 |
@@ -69,13 +73,13 @@ class AccessLevel(IntEnum): |
69 | 73 |
|
70 | 74 |
|
71 | 75 | # https://gitlab.com/gitlab-org/gitlab/-/blob/e97357824bedf007e75f8782259fe07435b64fbb/lib/gitlab/visibility_level.rb#L23-25 |
72 | | -class Visibility(Enum): |
| 76 | +class Visibility(GitlabEnum): |
73 | 77 | PRIVATE: str = "private" |
74 | 78 | INTERNAL: str = "internal" |
75 | 79 | PUBLIC: str = "public" |
76 | 80 |
|
77 | 81 |
|
78 | | -class NotificationLevel(Enum): |
| 82 | +class NotificationLevel(GitlabEnum): |
79 | 83 | DISABLED: str = "disabled" |
80 | 84 | PARTICIPATING: str = "participating" |
81 | 85 | WATCH: str = "watch" |
@@ -85,7 +89,7 @@ class NotificationLevel(Enum): |
85 | 89 |
|
86 | 90 |
|
87 | 91 | # https://gitlab.com/gitlab-org/gitlab/-/blob/e97357824bedf007e75f8782259fe07435b64fbb/app/views/search/_category.html.haml#L10-37 |
88 | | -class SearchScope(Enum): |
| 92 | +class SearchScope(GitlabEnum): |
89 | 93 | # all scopes (global, group and project) |
90 | 94 | PROJECTS: str = "projects" |
91 | 95 | ISSUES: str = "issues" |
|