mirror of
https://github.com/mkdocs/mkdocs.git
synced 2026-03-27 09:58:31 +07:00
Allow controlling Python warnings with python -W and PYTHONWARNINGS again
This commit is contained in:
@@ -46,12 +46,16 @@ def _showwarning(message, category, filename, lineno, file=None, line=None):
|
||||
|
||||
|
||||
def _enable_warnings():
|
||||
from mkdocs.commands import build
|
||||
# When `python -W...` or `PYTHONWARNINGS` are used, `sys.warnoptions` is set.
|
||||
# In that case, we skip warnings configuration since
|
||||
# we don't want to overwrite the user configuration.
|
||||
if not sys.warnoptions:
|
||||
from mkdocs.commands import build
|
||||
|
||||
build.log.addFilter(utils.DuplicateFilter())
|
||||
build.log.addFilter(utils.DuplicateFilter())
|
||||
|
||||
warnings.simplefilter('module', DeprecationWarning)
|
||||
warnings.showwarning = _showwarning
|
||||
warnings.simplefilter('module', DeprecationWarning)
|
||||
warnings.showwarning = _showwarning
|
||||
|
||||
|
||||
class ColorFormatter(logging.Formatter):
|
||||
|
||||
Reference in New Issue
Block a user