Fix lint.
This commit is contained in:
parent
17778f1457
commit
54557fee20
@ -29,6 +29,7 @@ import shutil
|
|||||||
import tempfile
|
import tempfile
|
||||||
import atexit
|
import atexit
|
||||||
import datetime
|
import datetime
|
||||||
|
import tokenize
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon, QCursor, QWindow
|
from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon, QCursor, QWindow
|
||||||
@ -483,7 +484,7 @@ class Quitter:
|
|||||||
for dirpath, _dirnames, filenames in os.walk(path):
|
for dirpath, _dirnames, filenames in os.walk(path):
|
||||||
for fn in filenames:
|
for fn in filenames:
|
||||||
if os.path.splitext(fn)[1] == '.py':
|
if os.path.splitext(fn)[1] == '.py':
|
||||||
with open(os.path.join(dirpath, fn)) as f:
|
with tokenize.open(os.path.join(dirpath, fn)) as f:
|
||||||
compile(f.read(), fn, 'exec')
|
compile(f.read(), fn, 'exec')
|
||||||
|
|
||||||
def _get_restart_args(self, pages=(), session=None):
|
def _get_restart_args(self, pages=(), session=None):
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import string
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
@ -36,6 +35,7 @@ from qutebrowser.browser import rfc6266
|
|||||||
|
|
||||||
|
|
||||||
def whitelist_generator():
|
def whitelist_generator():
|
||||||
|
"""Generator which yields lines to add to a vulture whitelist."""
|
||||||
# qutebrowser commands
|
# qutebrowser commands
|
||||||
for cmd in cmdutils.cmd_dict.values():
|
for cmd in cmdutils.cmd_dict.values():
|
||||||
yield utils.qualname(cmd.handler)
|
yield utils.qualname(cmd.handler)
|
||||||
@ -98,6 +98,12 @@ def whitelist_generator():
|
|||||||
|
|
||||||
|
|
||||||
def filter_func(item):
|
def filter_func(item):
|
||||||
|
"""Check if a missing function should be filtered or not.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
True if the missing function should be filtered/ignored, False
|
||||||
|
otherwise.
|
||||||
|
"""
|
||||||
if re.match(r'[a-z]+[A-Z][a-zA-Z]+', str(item)):
|
if re.match(r'[a-z]+[A-Z][a-zA-Z]+', str(item)):
|
||||||
# probably a virtual Qt method
|
# probably a virtual Qt method
|
||||||
return True
|
return True
|
||||||
@ -106,8 +112,13 @@ def filter_func(item):
|
|||||||
|
|
||||||
|
|
||||||
def report(items):
|
def report(items):
|
||||||
|
"""Generate a report based on the given vulture.Item's.
|
||||||
|
|
||||||
|
Based on vulture.Vulture.report, but we can't use that as we can't set the
|
||||||
|
properties which get used for the items.
|
||||||
|
"""
|
||||||
unused_item_found = False
|
unused_item_found = False
|
||||||
for item in sorted(items, key=lambda: (item.file.lower(), item.lineno)):
|
for item in sorted(items, key=lambda e: (e.file.lower(), e.lineno)):
|
||||||
relpath = os.path.relpath(item.file)
|
relpath = os.path.relpath(item.file)
|
||||||
path = relpath if not relpath.startswith('..') else item.file
|
path = relpath if not relpath.startswith('..') else item.file
|
||||||
print("%s:%d: Unused %s '%s'" % (path, item.lineno, item.typ,
|
print("%s:%d: Unused %s '%s'" % (path, item.lineno, item.typ,
|
||||||
@ -116,7 +127,8 @@ def report(items):
|
|||||||
return unused_item_found
|
return unused_item_found
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
|
"""Run vulture over all files."""
|
||||||
with tempfile.NamedTemporaryFile(mode='w', delete=False) as whitelist_file:
|
with tempfile.NamedTemporaryFile(mode='w', delete=False) as whitelist_file:
|
||||||
for line in whitelist_generator():
|
for line in whitelist_generator():
|
||||||
whitelist_file.write(line + '\n')
|
whitelist_file.write(line + '\n')
|
||||||
@ -145,3 +157,7 @@ if __name__ == '__main__':
|
|||||||
items.append(item)
|
items.append(item)
|
||||||
|
|
||||||
sys.exit(report(items))
|
sys.exit(report(items))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
1
tox.ini
1
tox.ini
@ -92,6 +92,7 @@ setenv = PYTHONPATH={toxinidir}/scripts/dev
|
|||||||
passenv =
|
passenv =
|
||||||
deps =
|
deps =
|
||||||
{[testenv:py34-integration]deps}
|
{[testenv:py34-integration]deps}
|
||||||
|
{[testenv:misc]deps}
|
||||||
astroid==1.3.8
|
astroid==1.3.8
|
||||||
pylint==1.4.4
|
pylint==1.4.4
|
||||||
logilab-common==1.0.2
|
logilab-common==1.0.2
|
||||||
|
Loading…
Reference in New Issue
Block a user