__init__.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  2. # For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
  3. # Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
  4. from __future__ import annotations
  5. __all__ = [
  6. "ConfigurationMixIn", # Deprecated
  7. "find_default_config_files",
  8. "find_pylintrc", # Deprecated
  9. "Option", # Deprecated
  10. "OptionsManagerMixIn", # Deprecated
  11. "OptionParser", # Deprecated
  12. "OptionsProviderMixIn", # Deprecated
  13. "UnsupportedAction", # Deprecated
  14. "PYLINTRC",
  15. "USER_HOME", # Compatibility with the old API
  16. "PYLINT_HOME", # Compatibility with the old API
  17. "save_results", # Compatibility with the old API # Deprecated
  18. "load_results", # Compatibility with the old API # Deprecated
  19. ]
  20. import warnings
  21. from pylint.config.arguments_provider import UnsupportedAction
  22. from pylint.config.configuration_mixin import ConfigurationMixIn
  23. from pylint.config.environment_variable import PYLINTRC
  24. from pylint.config.find_default_config_files import (
  25. find_default_config_files,
  26. find_pylintrc,
  27. )
  28. from pylint.config.option import Option
  29. from pylint.config.option_manager_mixin import OptionsManagerMixIn
  30. from pylint.config.option_parser import OptionParser # type: ignore[attr-defined]
  31. from pylint.config.options_provider_mixin import ( # type: ignore[attr-defined]
  32. OptionsProviderMixIn,
  33. )
  34. from pylint.constants import PYLINT_HOME, USER_HOME
  35. from pylint.utils import LinterStats
  36. def load_results(base: str) -> LinterStats | None:
  37. # TODO: 3.0: Remove deprecated function
  38. # pylint: disable=import-outside-toplevel
  39. from pylint.lint.caching import load_results as _real_load_results
  40. warnings.warn(
  41. "'pylint.config.load_results' is deprecated, please use "
  42. "'pylint.lint.load_results' instead. This will be removed in 3.0.",
  43. DeprecationWarning,
  44. stacklevel=2,
  45. )
  46. return _real_load_results(base, PYLINT_HOME)
  47. def save_results(results: LinterStats, base: str) -> None:
  48. # TODO: 3.0: Remove deprecated function
  49. # pylint: disable=import-outside-toplevel
  50. from pylint.lint.caching import save_results as _real_save_results
  51. warnings.warn(
  52. "'pylint.config.save_results' is deprecated, please use "
  53. "'pylint.lint.save_results' instead. This will be removed in 3.0.",
  54. DeprecationWarning,
  55. stacklevel=2,
  56. )
  57. return _real_save_results(results, base, PYLINT_HOME)