summaryrefslogtreecommitdiff
path: root/pylint/config/__init__.py
blob: 5f90bbae02ef3c2faef6f17fa6991662f4e0cac0 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt

from __future__ import annotations

__all__ = [
    "ConfigurationMixIn",  # Deprecated
    "find_default_config_files",
    "find_pylintrc",  # Deprecated
    "Option",  # Deprecated
    "OptionsManagerMixIn",  # Deprecated
    "OptionParser",  # Deprecated
    "OptionsProviderMixIn",  # Deprecated
    "UnsupportedAction",  # Deprecated
    "PYLINTRC",
    "USER_HOME",  # Compatibility with the old API
    "PYLINT_HOME",  # Compatibility with the old API
    "save_results",  # Compatibility with the old API # Deprecated
    "load_results",  # Compatibility with the old API # Deprecated
]

import warnings

from pylint.config.arguments_provider import UnsupportedAction
from pylint.config.configuration_mixin import ConfigurationMixIn
from pylint.config.environment_variable import PYLINTRC
from pylint.config.find_default_config_files import (
    find_default_config_files,
    find_pylintrc,
)
from pylint.config.option import Option
from pylint.config.option_manager_mixin import OptionsManagerMixIn
from pylint.config.option_parser import OptionParser  # type: ignore[attr-defined]
from pylint.config.options_provider_mixin import (  # type: ignore[attr-defined]
    OptionsProviderMixIn,
)
from pylint.constants import PYLINT_HOME, USER_HOME
from pylint.utils import LinterStats


def load_results(base: str) -> LinterStats | None:
    # TODO: 3.0: Remove deprecated function
    # pylint: disable=import-outside-toplevel
    from pylint.lint.caching import load_results as _real_load_results

    warnings.warn(
        "'pylint.config.load_results' is deprecated, please use "
        "'pylint.lint.load_results' instead. This will be removed in 3.0.",
        DeprecationWarning,
        stacklevel=2,
    )
    return _real_load_results(base, PYLINT_HOME)


def save_results(results: LinterStats, base: str) -> None:
    # TODO: 3.0: Remove deprecated function
    # pylint: disable=import-outside-toplevel
    from pylint.lint.caching import save_results as _real_save_results

    warnings.warn(
        "'pylint.config.save_results' is deprecated, please use "
        "'pylint.lint.save_results' instead. This will be removed in 3.0.",
        DeprecationWarning,
        stacklevel=2,
    )
    return _real_save_results(results, base, PYLINT_HOME)