From 03fbacd93c53a73c922749ecd8cbf0531e6ec286 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 29 Jun 2016 23:32:07 +0200 Subject: [PATCH] requirements: Update vulture to 0.9 * Don't flag attributes as unused if they are used as global variables in another module. * Don't consider "True" and "False" variable names. * Abort with error message when invoked on .pyc files. This means we can remove the whitelisted globals in run_vulture.py and the associated xfailing test. We also needed to adjust run_vulture.py slightly as the file attribute got renamed to filename. --- misc/requirements/requirements-tests.txt | 2 +- misc/requirements/requirements-vulture.txt | 2 +- scripts/dev/run_vulture.py | 14 +++---------- tests/unit/scripts/test_run_vulture.py | 23 ---------------------- 4 files changed, 5 insertions(+), 36 deletions(-) diff --git a/misc/requirements/requirements-tests.txt b/misc/requirements/requirements-tests.txt index b09d63ced..184974cf2 100644 --- a/misc/requirements/requirements-tests.txt +++ b/misc/requirements/requirements-tests.txt @@ -28,5 +28,5 @@ pytest-rerunfailures==2.0.0 pytest-travis-fold==1.2.0 pytest-xvfb==0.2.0 six==1.10.0 -vulture==0.8.1 +vulture==0.9 Werkzeug==0.11.10 diff --git a/misc/requirements/requirements-vulture.txt b/misc/requirements/requirements-vulture.txt index 47a2c6741..e3e35ba70 100644 --- a/misc/requirements/requirements-vulture.txt +++ b/misc/requirements/requirements-vulture.txt @@ -1,3 +1,3 @@ # This file is automatically generated by scripts/dev/recompile_requirements.py -vulture==0.8.1 +vulture==0.9 diff --git a/scripts/dev/run_vulture.py b/scripts/dev/run_vulture.py index bc09717e6..b894377cf 100755 --- a/scripts/dev/run_vulture.py +++ b/scripts/dev/run_vulture.py @@ -77,14 +77,6 @@ def whitelist_generator(): for func in qutescheme.HANDLERS.values(): yield 'qutebrowser.browser.webkit.network.qutescheme.' + func.__name__ - # Globals - # https://bitbucket.org/jendrikseipp/vulture/issues/10/ - yield 'qutebrowser.misc.utilcmds.pyeval_output' - yield 'utils.use_color' - yield 'qutebrowser.browser.webkit.mhtml.last_used_directory' - yield 'qutebrowser.utils.utils.fake_clipboard' - yield 'qutebrowser.utils.utils.log_clipboard' - # Other false-positives yield ('qutebrowser.completion.models.sortfilter.CompletionFilterModel().' 'lessThan') @@ -127,9 +119,9 @@ def report(items): properties which get used for the items. """ output = [] - for item in sorted(items, key=lambda e: (e.file.lower(), e.lineno)): - relpath = os.path.relpath(item.file) - path = relpath if not relpath.startswith('..') else item.file + for item in sorted(items, key=lambda e: (e.filename.lower(), e.lineno)): + relpath = os.path.relpath(item.filename) + path = relpath if not relpath.startswith('..') else item.filename output.append("{}:{}: Unused {} '{}'".format(path, item.lineno, item.typ, item)) return output diff --git a/tests/unit/scripts/test_run_vulture.py b/tests/unit/scripts/test_run_vulture.py index f2427c11c..91f7a0744 100644 --- a/tests/unit/scripts/test_run_vulture.py +++ b/tests/unit/scripts/test_run_vulture.py @@ -138,26 +138,3 @@ def test_unused_method_camelcase(vultdir): Foo() """) assert not vultdir.run() - - -@pytest.mark.xfail( - True, reason="https://bitbucket.org/jendrikseipp/vulture/issues/10/") -def test_globals_bug(vultdir): - """Vulture has a bug where it detects globals as unused. - - When this test starts XPASSing, we know it's been fixed. - """ - vultdir.makepyfile(foo=""" - import bar - - bar.attr = True - bar.blub() - """) - vultdir.makepyfile(bar=""" - attr = False - - def blub(): - if attr: - print("Hey!") - """) - assert not vultdir.run()