diff options
author | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-04-15 12:27:46 +0200 |
---|---|---|
committer | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-04-15 13:01:35 +0200 |
commit | 2f7cb9870c61592bf663359fb21250e007c022fe (patch) | |
tree | acefaaaa6672bb585ac379d07b340aa66952b9b2 /pylint/utils | |
parent | 63173f8f3a21671155c9a3122c5ecaa8a66ce0b5 (diff) | |
download | pylint-git-2f7cb9870c61592bf663359fb21250e007c022fe.tar.gz |
Deprecate ``get_global_option``
Diffstat (limited to 'pylint/utils')
-rw-r--r-- | pylint/utils/utils.py | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py index 0214d3fac..23a2d8098 100644 --- a/pylint/utils/utils.py +++ b/pylint/utils/utils.py @@ -247,36 +247,21 @@ def get_global_option( def get_global_option( checker: BaseChecker, option: GLOBAL_OPTION_NAMES, - default: T_GlobalOptionReturnTypes | None = None, + default: T_GlobalOptionReturnTypes | None = None, # pylint: disable=unused-argument ) -> T_GlobalOptionReturnTypes | None: - """Retrieve an option defined by the given *checker* or + """DEPRECATED: Retrieve an option defined by the given *checker* or by all known option providers. It will look in the list of all options providers until the given *option* will be found. If the option wasn't found, the *default* value will be returned. """ - - # # pylint: disable-next=fixme - # # TODO: Optparse: Potentially deprecate this. - # Firstly, try on the namespace object - try: - return getattr(checker.linter.config, option.replace("-", "_")) - except AttributeError: - pass - - # First, try in the given checker's config. - # After that, look in the options providers. - - try: - return getattr(checker.config, option.replace("-", "_")) - except AttributeError: - pass - for provider in checker.linter.options_providers: - for options in provider.options: - if options[0] == option: - return getattr(provider.config, option.replace("-", "_")) - return default + warnings.warn( + "get_global_option has been deprecated. You can use " + "checker.linter.config to get all global options instead.", + DeprecationWarning, + ) + return getattr(checker.linter.config, option.replace("-", "_")) def _splitstrip(string: str, sep: str = ",") -> list[str]: |