diff options
author | Yilei "Dolee" Yang <yileiyang@google.com> | 2022-09-15 03:36:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-15 12:36:41 +0200 |
commit | a57edea63fa7a1edfcb63074f9e2a373ebabb7cd (patch) | |
tree | d7a18bd93116036518ddeed2a2253e72a2a7f5fc /pylint/utils | |
parent | 27925396c85ffc443243589a0c03e430de9d7fa5 (diff) | |
download | pylint-git-a57edea63fa7a1edfcb63074f9e2a373ebabb7cd.tar.gz |
Use stacklevel=2 in warnings.warn calls to DeprecationWarning where makes sense. (#7465)
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'pylint/utils')
-rw-r--r-- | pylint/utils/file_state.py | 3 | ||||
-rw-r--r-- | pylint/utils/utils.py | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/pylint/utils/file_state.py b/pylint/utils/file_state.py index bf0bd58d6..19122b373 100644 --- a/pylint/utils/file_state.py +++ b/pylint/utils/file_state.py @@ -47,12 +47,14 @@ class FileState: "FileState needs a string as modname argument. " "This argument will be required in pylint 3.0", DeprecationWarning, + stacklevel=2, ) if msg_store is None: warnings.warn( "FileState needs a 'MessageDefinitionStore' as msg_store argument. " "This argument will be required in pylint 3.0", DeprecationWarning, + stacklevel=2, ) self.base_name = modname self._module_msgs_state: MessageStateDict = {} @@ -79,6 +81,7 @@ class FileState: warnings.warn( "'collect_block_lines' has been deprecated and will be removed in pylint 3.0.", DeprecationWarning, + stacklevel=2, ) for msg, lines in self._module_msgs_state.items(): self._raw_module_msgs_state[msg] = lines.copy() diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py index 3621a35af..054d307bc 100644 --- a/pylint/utils/utils.py +++ b/pylint/utils/utils.py @@ -281,6 +281,7 @@ def get_global_option( "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("-", "_")) @@ -367,6 +368,7 @@ def format_section( warnings.warn( "format_section has been deprecated. It will be removed in pylint 3.0.", DeprecationWarning, + stacklevel=2, ) if doc: print(_comment(doc), file=stream) @@ -381,6 +383,7 @@ def _ini_format(stream: TextIO, options: list[tuple[str, OptionDict, Any]]) -> N warnings.warn( "_ini_format has been deprecated. It will be removed in pylint 3.0.", DeprecationWarning, + stacklevel=2, ) for optname, optdict, value in options: # Skip deprecated option |