core.warnings: handle stacklevel properly
add more warnings about deprecated config arguments
This commit is contained in:
parent
59f355fbec
commit
2cb9d1e238
4 changed files with 18 additions and 12 deletions
|
@ -8,6 +8,8 @@ E.g. would be nice to propagate the warnings in the UI (it's even a subclass of
|
|||
import sys
|
||||
import warnings
|
||||
|
||||
# just bring in the scope of this module for convenience
|
||||
from warnings import warn
|
||||
|
||||
def _colorize(x: str, color=None) -> str:
|
||||
if color is None:
|
||||
|
@ -28,8 +30,8 @@ def _colorize(x: str, color=None) -> str:
|
|||
|
||||
|
||||
def _warn(message: str, *args, color=None, **kwargs) -> None:
|
||||
if 'stacklevel' not in kwargs:
|
||||
kwargs['stacklevel'] = 3 # 1 for this function, 1 for medium/high wrapper
|
||||
stacklevel = kwargs.get('stacklevel', 1)
|
||||
kwargs['stacklevel'] = stacklevel + 2 # +1 for this function, +1 for medium/high wrapper
|
||||
warnings.warn(_colorize(message, color=color), *args, **kwargs)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue