diff options
author | John L. Villalovos <john@sodarock.com> | 2021-11-30 08:37:46 -0800 |
---|---|---|
committer | John L. Villalovos <john@sodarock.com> | 2021-11-30 08:37:46 -0800 |
commit | c0aa0e1c9f7d7914e3062fe6503da870508b27cf (patch) | |
tree | c141f76fef50bfbefb3d0806ccdf7c24c106f799 /gitlab/const.py | |
parent | 09a973ee379d82af05a5080decfaec16d2f4eab3 (diff) | |
download | gitlab-c0aa0e1c9f7d7914e3062fe6503da870508b27cf.tar.gz |
refactor: deprecate accessing constants from top-level namespace
We are planning on adding enumerated constants into gitlab/const.py,
but if we do that than they will end up being added to the top-level
gitlab namespace. We really want to get users to start using
`gitlab.const.` to access the constant values in the future.
Add the currently defined constants to a list that should not change.
Use a module level __getattr__ function so that we can deprecate
access to the top-level constants.
Add a unit test which verifies we generate a warning when accessing
the top-level constants.
Diffstat (limited to 'gitlab/const.py')
-rw-r--r-- | gitlab/const.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gitlab/const.py b/gitlab/const.py index 12faf88..48aa96d 100644 --- a/gitlab/const.py +++ b/gitlab/const.py @@ -17,6 +17,41 @@ from gitlab.__version__ import __title__, __version__ +# NOTE(jlvillal): '_DEPRECATED' only affects users accessing constants via the +# top-level gitlab.* namespace. See 'gitlab/__init__.py:__getattr__()' for the +# consumer of '_DEPRECATED' For example 'x = gitlab.NO_ACCESS'. We want users +# to instead use constants by doing code like: gitlab.const.NO_ACCESS. +_DEPRECATED = [ + "DEFAULT_URL", + "DEVELOPER_ACCESS", + "GUEST_ACCESS", + "MAINTAINER_ACCESS", + "MINIMAL_ACCESS", + "NO_ACCESS", + "NOTIFICATION_LEVEL_CUSTOM", + "NOTIFICATION_LEVEL_DISABLED", + "NOTIFICATION_LEVEL_GLOBAL", + "NOTIFICATION_LEVEL_MENTION", + "NOTIFICATION_LEVEL_PARTICIPATING", + "NOTIFICATION_LEVEL_WATCH", + "OWNER_ACCESS", + "REPORTER_ACCESS", + "SEARCH_SCOPE_BLOBS", + "SEARCH_SCOPE_COMMITS", + "SEARCH_SCOPE_GLOBAL_SNIPPET_TITLES", + "SEARCH_SCOPE_ISSUES", + "SEARCH_SCOPE_MERGE_REQUESTS", + "SEARCH_SCOPE_MILESTONES", + "SEARCH_SCOPE_PROJECT_NOTES", + "SEARCH_SCOPE_PROJECTS", + "SEARCH_SCOPE_USERS", + "SEARCH_SCOPE_WIKI_BLOBS", + "USER_AGENT", + "VISIBILITY_INTERNAL", + "VISIBILITY_PRIVATE", + "VISIBILITY_PUBLIC", +] + DEFAULT_URL: str = "https://gitlab.com" NO_ACCESS: int = 0 |