From 5a319cc50533c65629000a7e235d14a5e275c55f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 16 Feb 2019 20:10:29 +0100 Subject: [PATCH] Be more strict about Python deprecation warnings again The warnings caught in earlyinit.py got fixed in the affected dependencies. The collections.abc warning also seems to be fixed in everything but PyYAML. --- pytest.ini | 2 -- qutebrowser/misc/earlyinit.py | 20 +------------------- qutebrowser/utils/utils.py | 10 +++++++++- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/pytest.ini b/pytest.ini index ff2b606ef..49f23359b 100644 --- a/pytest.ini +++ b/pytest.ini @@ -68,7 +68,5 @@ qt_log_ignore = xfail_strict = true filterwarnings = error - # This happens in many qutebrowser dependencies... - ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working:DeprecationWarning # WORKAROUND for https://github.com/pytest-dev/pytest-bdd/pull/288 ignore:the `pytest\.config` global is deprecated\. Please use `request.config` or `pytest_configure` \(if you're a pytest plugin\) instead\. diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py index 690ede60f..02e3564a2 100644 --- a/qutebrowser/misc/earlyinit.py +++ b/qutebrowser/misc/earlyinit.py @@ -199,25 +199,7 @@ def _check_modules(modules): for name, text in modules.items(): try: - # https://github.com/pallets/jinja/pull/628 - # https://bitbucket.org/birkenfeld/pygments-main/issues/1314/ - # https://github.com/pallets/jinja/issues/646 - # https://bitbucket.org/fdik/pypeg/commits/dd15ca462b532019c0a3be1d39b8ee2f3fa32f4e - messages = ['invalid escape sequence', - 'Flags not at the start of the expression'] - # pylint: disable=bad-continuation - with log.ignore_py_warnings( - category=DeprecationWarning, - message=r'({})'.format('|'.join(messages)) - ), log.ignore_py_warnings( - category=PendingDeprecationWarning, - module='imp' - ), log.ignore_py_warnings( - category=ImportWarning, - message=r'Not importing directory .*: missing __init__' - ): - # pylint: enable=bad-continuation - importlib.import_module(name) + importlib.import_module(name) except ImportError as e: _die(text, e) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 2d517043a..760bce576 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -655,7 +655,15 @@ def expand_windows_drive(path): def yaml_load(f): """Wrapper over yaml.load using the C loader if possible.""" start = datetime.datetime.now() - data = yaml.load(f, Loader=YamlLoader) + + # WORKAROUND for https://github.com/yaml/pyyaml/pull/181 + with log.ignore_py_warnings( + category=DeprecationWarning, + message=r"Using or importing the ABCs from 'collections' instead " + r"of from 'collections\.abc' is deprecated, and in 3\.8 it will " + r"stop working"): + data = yaml.load(f, Loader=YamlLoader) + end = datetime.datetime.now() delta = (end - start).total_seconds()