summaryrefslogtreecommitdiff
path: root/gitlab/__init__.py
blob: 5f168acb2a1bde90c0d652127bf7242523b7e664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
#
# Copyright (C) 2013-2017 Gauvain Pocentek <gauvain@pocentek.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""Wrapper for the GitLab API."""

import warnings
from typing import Any

import gitlab.config  # noqa: F401
from gitlab._version import (  # noqa: F401
    __author__,
    __copyright__,
    __email__,
    __license__,
    __title__,
    __version__,
)
from gitlab.client import Gitlab, GitlabList  # noqa: F401
from gitlab.exceptions import *  # noqa: F401,F403

warnings.filterwarnings("default", category=DeprecationWarning, module="^gitlab")


# NOTE(jlvillal): We are deprecating access to the gitlab.const values which
# were previously imported into this namespace by the
# 'from gitlab.const import *' statement.
def __getattr__(name: str) -> Any:
    # Deprecate direct access to constants without namespace
    if name in gitlab.const._DEPRECATED:
        warnings.warn(
            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.",
            DeprecationWarning,
        )
        return getattr(gitlab.const, name)
    raise AttributeError(f"module {__name__} has no attribute {name}")