diff options
Diffstat (limited to 'pylint/utils/utils.py')
-rw-r--r-- | pylint/utils/utils.py | 85 |
1 files changed, 4 insertions, 81 deletions
diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py index 054d307bc..543d7cbb3 100644 --- a/pylint/utils/utils.py +++ b/pylint/utils/utils.py @@ -1,6 +1,6 @@ # 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 +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt from __future__ import annotations @@ -28,12 +28,12 @@ from typing import ( TYPE_CHECKING, Any, List, + Literal, Pattern, TextIO, Tuple, TypeVar, Union, - overload, ) from astroid import Module, modutils, nodes @@ -41,13 +41,7 @@ from astroid import Module, modutils, nodes from pylint.constants import PY_EXTS from pylint.typing import OptionDict -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal - if TYPE_CHECKING: - from pylint.checkers.base_checker import BaseChecker from pylint.lint import PyLinter DEFAULT_LINE_LENGTH = 79 @@ -215,77 +209,6 @@ def register_plugins(linter: PyLinter, directory: str) -> None: imported[base] = 1 -@overload -def get_global_option( - checker: BaseChecker, option: GLOBAL_OPTION_BOOL, default: bool | None = ... -) -> bool: - ... - - -@overload -def get_global_option( - checker: BaseChecker, option: GLOBAL_OPTION_INT, default: int | None = ... -) -> int: - ... - - -@overload -def get_global_option( - checker: BaseChecker, - option: GLOBAL_OPTION_LIST, - default: list[str] | None = ..., -) -> list[str]: - ... - - -@overload -def get_global_option( - checker: BaseChecker, - option: GLOBAL_OPTION_PATTERN, - default: Pattern[str] | None = ..., -) -> Pattern[str]: - ... - - -@overload -def get_global_option( - checker: BaseChecker, - option: GLOBAL_OPTION_PATTERN_LIST, - default: list[Pattern[str]] | None = ..., -) -> list[Pattern[str]]: - ... - - -@overload -def get_global_option( - checker: BaseChecker, - option: GLOBAL_OPTION_TUPLE_INT, - default: tuple[int, ...] | None = ..., -) -> tuple[int, ...]: - ... - - -def get_global_option( - checker: BaseChecker, - option: GLOBAL_OPTION_NAMES, - default: T_GlobalOptionReturnTypes | None = None, # pylint: disable=unused-argument -) -> T_GlobalOptionReturnTypes | None | Any: - """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. - """ - warnings.warn( - "get_global_option has been deprecated. You can use " - "checker.linter.config to get all global options instead.", - DeprecationWarning, - stacklevel=2, - ) - return getattr(checker.linter.config, option.replace("-", "_")) - - def _splitstrip(string: str, sep: str = ",") -> list[str]: """Return a list of stripped string by splitting the string given as argument on `sep` (',' by default), empty strings are discarded. @@ -340,7 +263,7 @@ def _comment(string: str) -> str: def _format_option_value(optdict: OptionDict, value: Any) -> str: """Return the user input's value from a 'compiled' value. - TODO: 3.0: Remove deprecated function + TODO: Refactor the code to not use this deprecated function """ if optdict.get("type", None) == "py_version": value = ".".join(str(item) for item in value) |