Adjust pylint exceptions.

This commit is contained in:
Florian Bruhin 2015-03-11 20:14:39 +01:00
parent cd14ae2f1f
commit e8e6d8409b
24 changed files with 47 additions and 44 deletions

View File

@ -26,7 +26,11 @@ disable=no-self-use,
blacklisted-name,
too-many-lines,
logging-format-interpolation,
interface-not-implemented
interface-not-implemented,
broad-except,
bare-except,
eval-used,
exec-used
[BASIC]
module-rgx=(__)?[a-z][a-z0-9_]*(__)?$

View File

@ -14,7 +14,7 @@ exclude=test_.*
args=--output-format=colorized,--reports=no,--rcfile=.pylintrc
plugins=config,crlf,modeline,settrace,openencoding
# excluding command.py is a WORKAROUND for https://bitbucket.org/logilab/pylint/issue/395/horrible-performance-related-to-inspect
exclude=resources.py,command.py
exclude=resources.py
[flake8]
args=--config=.flake8

View File

@ -487,7 +487,7 @@ class Application(QApplication):
QUrl.RemovePassword | QUrl.FullyEncoded)
if urlstr:
win_pages.append(urlstr)
except Exception: # pylint: disable=broad-except
except Exception:
if forgiving:
log.destroy.exception("Error while recovering tab")
else:
@ -538,8 +538,6 @@ class Application(QApplication):
It'll try very hard to write all open tabs to a file, and then exit
gracefully.
"""
# pylint: disable=broad-except
exc = (exctype, excvalue, tb)
if not self._quit_status['crash']:
@ -682,9 +680,9 @@ class Application(QApplication):
s: The string to evaluate.
"""
try:
r = eval(s) # pylint: disable=eval-used
r = eval(s)
out = repr(r)
except Exception: # pylint: disable=broad-except
except Exception:
out = traceback.format_exc()
qutescheme.pyeval_output = out
tabbed_browser = objreg.get('tabbed-browser', scope='window',

View File

@ -951,8 +951,8 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window')
def view_source(self):
"""Show the source of the current page."""
# pylint doesn't seem to like pygments...
# pylint: disable=no-member
# https://bitbucket.org/logilab/pylint/issue/491/
widget = self._current_widget()
if widget.viewing_source:
raise cmdexc.CommandError("Already viewing source!")

View File

@ -19,7 +19,9 @@
#
# pylint complains when using .render() on jinja templates, so we make it shut
# up for this whole module.
# pylint: disable=maybe-no-member
# pylint: disable=no-member
# https://bitbucket.org/logilab/pylint/issue/490/
"""Handler functions for different qute:... pages.

View File

@ -24,8 +24,7 @@ import urllib.parse
import string
import re
import pypeg2 as peg # pylint: disable=import-error
# (fails on win7 in venv...)
import pypeg2 as peg
from qutebrowser.utils import log, utils
@ -293,7 +292,9 @@ def normalize_ws(text):
def parse_headers(content_disposition):
"""Build a ContentDisposition from header values."""
# pylint: disable=maybe-no-member
# https://bitbucket.org/logilab/pylint/issue/492/
# pylint: disable=no-member
# We allow non-ascii here (it will only be parsed inside of qdtext, and
# rejected by the grammar if it appears in other places), although parsing
# it can be ambiguous. Parsing it ensures that a non-ambiguous filename*

View File

@ -163,7 +163,9 @@ class BrowserPage(QWebPage):
info.domain, info.error))
title = "Error loading page: {}".format(urlstr)
template = jinja.env.get_template('error.html')
html = template.render( # pylint: disable=maybe-no-member
# pylint: disable=no-member
# https://bitbucket.org/logilab/pylint/issue/490/
html = template.render(
title=title, url=urlstr, error=error_str, icon='')
errpage.content = html.encode('utf-8')
errpage.encoding = 'utf-8'

View File

@ -79,6 +79,7 @@ class SettingValue:
if val is not None:
return val
else: # pylint: disable=useless-else-on-loop
# https://bitbucket.org/logilab/pylint/issue/489/
raise ValueError("No valid config value found!")
def transformed(self):

View File

@ -166,7 +166,7 @@ class BaseKeyParser(QObject):
return self.Match.none
if len(txt) == 1:
category = unicodedata.category(txt) # pylint: disable=no-member
category = unicodedata.category(txt)
is_control_char = (category == 'Cc')
else:
is_control_char = False

View File

@ -183,7 +183,7 @@ class MainWindow(QWidget):
def _connect_signals(self):
"""Connect all mainwindow signals."""
# pylint: disable=too-many-locals,too-many-statements
# pylint: disable=too-many-statements
key_config = objreg.get('key-config')
status = self._get_object('statusbar')

View File

@ -202,7 +202,6 @@ class StatusBar(QWidget):
Return:
The severity as a string (!)
"""
# pylint: disable=method-hidden
if self._severity is None:
return ""
else:
@ -233,7 +232,6 @@ class StatusBar(QWidget):
@pyqtProperty(bool)
def prompt_active(self):
"""Getter for self.prompt_active, so it can be used as Qt property."""
# pylint: disable=method-hidden
return self._prompt_active
def _set_prompt_active(self, val):
@ -249,7 +247,6 @@ class StatusBar(QWidget):
@pyqtProperty(bool)
def insert_active(self):
"""Getter for self.insert_active, so it can be used as Qt property."""
# pylint: disable=method-hidden
return self._insert_active
def _set_insert_active(self, val):

View File

@ -90,7 +90,6 @@ class UrlText(textbase.TextBase):
Return:
The urltype as a string (!)
"""
# pylint: disable=method-hidden
if self._urltype is None:
return ""
else:

View File

@ -17,8 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=broad-except
"""The dialog which gets shown when qutebrowser crashes."""
import re

View File

@ -54,7 +54,7 @@ def later(ms: {'type': int}, command, win_id: {'special': 'win_id'}):
functools.partial(commandrunner.run_safely, command))
timer.timeout.connect(timer.deleteLater)
timer.start()
except: # pylint: disable=bare-except
except:
timer.deleteLater()
raise
@ -85,7 +85,7 @@ def debug_crash(typ: {'type': ('exception', 'segfault')}='exception'):
# From python's Lib/test/crashers/bogus_code_obj.py
co = types.CodeType(0, 0, 0, 0, 0, b'\x04\x71\x00\x00', (), (), (),
'', '', 1, b'')
exec(co) # pylint: disable=exec-used
exec(co)
raise Exception("Segfault failed (wat.)")
else:
raise Exception("Forced crash")

View File

@ -124,7 +124,7 @@ def main():
WARNING: misc/crashdialog.py checks the stacktrace for this function
name, so if this is changed, it should be changed there as well!
"""
return app.exec_() # pylint: disable=maybe-no-member
return app.exec_()
# We set qApp explicitely here to reduce the risk of segfaults while
# quitting.

View File

@ -69,7 +69,6 @@ class ConfigParserTests(unittest.TestCase):
"""Test a transformed option with the old name."""
# WORKAROUND for unknown PyQt bug
# Instance of 'str' has no 'name' member
# pylint: disable=no-member
self.cp.read_dict({'colors': {'tab.fg.odd': 'pink'}})
self.cfg._from_cp(self.cp)
self.assertEqual(self.cfg.get('colors', 'tabs.fg.odd').name(),
@ -79,7 +78,6 @@ class ConfigParserTests(unittest.TestCase):
"""Test a transformed section with the new name."""
# WORKAROUND for unknown PyQt bug
# Instance of 'str' has no 'name' member
# pylint: disable=no-member
self.cp.read_dict({'colors': {'tabs.fg.odd': 'pink'}})
self.cfg._from_cp(self.cp)
self.assertEqual(self.cfg.get('colors', 'tabs.fg.odd').name(),

View File

@ -210,8 +210,6 @@ class ErrorMessageTests(unittest.TestCase):
editor: The ExternalEditor instance to test.
"""
# pylint: disable=maybe-no-member
def setUp(self):
self.editor = editor.ExternalEditor(0)

View File

@ -43,7 +43,8 @@ class JinjaTests(unittest.TestCase):
"""Test with a simple template."""
readfile_mock.side_effect = _read_file
template = jinja.env.get_template('test.html')
data = template.render(var='World') # pylint: disable=maybe-no-member
# https://bitbucket.org/logilab/pylint/issue/490/
data = template.render(var='World') # pylint: disable=no-member
self.assertEqual(data, "Hello World")
def test_utf8(self, readfile_mock):
@ -56,7 +57,8 @@ class JinjaTests(unittest.TestCase):
"""
readfile_mock.side_effect = _read_file
template = jinja.env.get_template('test.html')
data = template.render(var='\u2603') # pylint: disable=maybe-no-member
# https://bitbucket.org/logilab/pylint/issue/490/
data = template.render(var='\u2603') # pylint: disable=no-member
self.assertEqual(data, "Hello \u2603")

View File

@ -32,12 +32,10 @@ from PyQt5.QtCore import (QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg,
qInstallMessageHandler)
# Optional imports
try:
# pylint: disable=import-error
import colorama
except ImportError:
colorama = None
try:
# pylint: disable=import-error
import colorlog
except ImportError:
colorlog = None

View File

@ -183,7 +183,7 @@ def savefile_open(filename, binary=False, encoding='utf-8'):
new_f = None
try:
ok = f.open(QIODevice.WriteOnly)
if not ok: # pylint: disable=used-before-assignment
if not ok:
raise OSError(f.errorString())
if binary:
new_f = PyQIODevice(f)
@ -196,8 +196,8 @@ def savefile_open(filename, binary=False, encoding='utf-8'):
finally:
if new_f is not None:
new_f.flush()
ok = f.commit()
if not ok:
commit_ok = f.commit()
if not commit_ok:
raise OSError(f.errorString())

View File

@ -171,8 +171,6 @@ def _os_info():
Return:
A list of lines with version info.
"""
# pylint has issues with platform.mac_ver()
# pylint: disable=unpacking-non-sequence
lines = []
releaseinfo = None
if sys.platform == 'linux':
@ -181,6 +179,8 @@ def _os_info():
elif sys.platform == 'win32':
osver = ', '.join(platform.win32_ver())
elif sys.platform == 'darwin':
# pylint: disable=unpacking-non-sequence
# See https://bitbucket.org/logilab/pylint/issue/165/
release, versioninfo, machine = platform.mac_ver()
if all(not e for e in versioninfo):
versioninfo = ''

View File

@ -18,8 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=broad-except
"""Check by which hostblock list a host was blocked."""
import sys

View File

@ -18,8 +18,6 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=broad-except
""" Run different codecheckers over a codebase.
Runs flake8, pylint, pep257, a CRLF/whitespace/conflict-checker and
@ -81,7 +79,6 @@ def run(name, target=None, print_version=False):
target: The package to check
print_version: Whether to print the checker version.
"""
# pylint: disable=too-many-branches
args = _get_args(name)
if target is not None:
args.append(target)
@ -112,7 +109,6 @@ def check_pep257(target, print_version=False):
We use this rather than run() because on some systems (e.g. Windows) no
pep257 binary is available.
"""
# pylint: disable=assignment-from-no-return,no-member
if print_version:
print(pep257.__version__)
args = _get_args('pep257')
@ -120,6 +116,7 @@ def check_pep257(target, print_version=False):
if args is not None:
sys.argv += args
try:
# pylint: disable=assignment-from-no-return,no-member
if hasattr(pep257, 'run_pep257'):
# newer pep257 versions
status = pep257.run_pep257()
@ -219,6 +216,8 @@ def check_vcs_conflict(target):
def _get_optional_args(checker):
"""Get a list of arguments based on a comma-separated args config."""
# pylint: disable=no-member
# https://bitbucket.org/logilab/pylint/issue/487/
try:
return config.get(checker, 'args').split(',')
except configparser.NoOptionError:
@ -239,6 +238,8 @@ def _get_args(checker):
Return:
A list of commandline arguments.
"""
# pylint: disable=no-member
# https://bitbucket.org/logilab/pylint/issue/487/
args = []
if checker == 'pylint':
args += _get_flag('disable', 'pylint', 'disable')
@ -275,6 +276,8 @@ def _get_args(checker):
def _get_checkers(args):
"""Get a dict of checkers we need to execute."""
# pylint: disable=no-member
# https://bitbucket.org/logilab/pylint/issue/487/
# "Static" checkers
checkers = collections.OrderedDict([
('global', collections.OrderedDict([
@ -303,6 +306,8 @@ def _get_checkers(args):
def _checker_enabled(args, group, name):
"""Check if a named checker is enabled."""
# pylint: disable=no-member
# https://bitbucket.org/logilab/pylint/issue/487/
if args.checkers == 'all':
if not args.setup and group == 'setup':
return False
@ -333,6 +338,8 @@ def _parse_args():
def main():
"""Main entry point."""
# pylint: disable=no-member
# https://bitbucket.org/logilab/pylint/issue/487/
utils.change_cwd()
read_files = config.read('.run_checks')
if not read_files:

View File

@ -367,7 +367,7 @@ def _format_block(filename, what, data):
elif not found_end:
raise Exception("Marker '// QUTE_{}_END' not found in "
"'{}'!".format(what, filename))
except: # pylint: disable=bare-except
except:
os.remove(tmpname)
raise
else: