From 58fb2826ee434bf795f4f56e94b06be8abb3ed05 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 21 Jan 2016 22:53:53 +0100 Subject: [PATCH] flake8: Add flake8-putty plugin. Apply a bit of putty to flake8. https://pypi.python.org/pypi/flake8-putty/ --- qutebrowser/browser/network/networkreply.py | 3 ++- qutebrowser/commands/cmdutils.py | 2 +- qutebrowser/config/config.py | 2 +- qutebrowser/keyinput/modeman.py | 2 +- qutebrowser/misc/crashsignal.py | 2 +- qutebrowser/misc/split.py | 2 +- qutebrowser/utils/debug.py | 2 +- qutebrowser/utils/log.py | 4 ++-- qutebrowser/utils/utils.py | 2 +- setup.cfg | 7 +++++++ tests/unit/utils/test_debug.py | 4 ++-- tests/unit/utils/usertypes/test_enum.py | 2 +- tox.ini | 1 + 13 files changed, 22 insertions(+), 13 deletions(-) diff --git a/qutebrowser/browser/network/networkreply.py b/qutebrowser/browser/network/networkreply.py index 71f82c39e..2cc5727be 100644 --- a/qutebrowser/browser/network/networkreply.py +++ b/qutebrowser/browser/network/networkreply.py @@ -30,7 +30,8 @@ class FixedDataNetworkReply(QNetworkReply): """QNetworkReply subclass for fixed data.""" - def __init__(self, request, fileData, mimeType, parent=None): # noqa + def __init__(self, request, fileData, mimeType, # flake8: disable=N803 + parent=None): """Constructor. Args: diff --git a/qutebrowser/commands/cmdutils.py b/qutebrowser/commands/cmdutils.py index 54def33a7..45b542189 100644 --- a/qutebrowser/commands/cmdutils.py +++ b/qutebrowser/commands/cmdutils.py @@ -91,7 +91,7 @@ def check_exclusive(flags, names): argstr)) -class register: # noqa # pylint: disable=invalid-name +class register: # pylint: disable=invalid-name """Decorator to register a new command handler. diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 889887728..af901a29d 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -46,7 +46,7 @@ from qutebrowser.utils.usertypes import Completion UNSET = object() -class change_filter: # noqa # pylint: disable=invalid-name +class change_filter: # pylint: disable=invalid-name """Decorator to filter calls based on a config section/option matching. diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index c7d245c83..21c579761 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -65,7 +65,7 @@ class NotInModeError(Exception): def init(win_id, parent): """Initialize the mode manager and the keyparsers for the given win_id.""" - KM = usertypes.KeyMode # noqa # pylint: disable=invalid-name + KM = usertypes.KeyMode # pylint: disable=invalid-name modeman = ModeManager(win_id, parent) objreg.register('mode-manager', modeman, scope='window', window=win_id) keyparsers = { diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py index 47e70d808..22ed19d79 100644 --- a/qutebrowser/misc/crashsignal.py +++ b/qutebrowser/misc/crashsignal.py @@ -22,7 +22,7 @@ import os import sys import bdb -import pdb # noqa +import pdb # flake8: disable=T002 import signal import functools import faulthandler diff --git a/qutebrowser/misc/split.py b/qutebrowser/misc/split.py index a0382f365..0fd4f96c3 100644 --- a/qutebrowser/misc/split.py +++ b/qutebrowser/misc/split.py @@ -55,7 +55,7 @@ class ShellLexer: self.token = '' self.state = ' ' - def __iter__(self): # noqa + def __iter__(self): # pragma: no mccabe """Read a raw token from the input stream.""" # pylint: disable=too-many-branches,too-many-statements self.reset() diff --git a/qutebrowser/utils/debug.py b/qutebrowser/utils/debug.py index 33b113945..09aa314e5 100644 --- a/qutebrowser/utils/debug.py +++ b/qutebrowser/utils/debug.py @@ -224,7 +224,7 @@ def format_call(func, args=None, kwargs=None, full=True): return '{}({})'.format(name, format_args(args, kwargs)) -class log_time: # noqa pylint: disable=invalid-name +class log_time: # pylint: disable=invalid-name """Log the time an operation takes. diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index e80909aa9..1d73194e7 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -274,7 +274,7 @@ def qt_message_handler(msg_type, context, msg): # PNGs in Qt with broken color profile # https://bugreports.qt.io/browse/QTBUG-39788 'libpng warning: iCCP: Not recognizing known sRGB profile that has ' - 'been edited', # noqa + 'been edited', # flake8: disable=E131 'libpng warning: iCCP: known incorrect sRGB profile', # Hopefully harmless warning 'OpenType support missing for script ', @@ -312,7 +312,7 @@ def qt_message_handler(msg_type, context, msg): 'libpng warning: iCCP: known incorrect sRGB profile', # https://bugreports.qt.io/browse/QTBUG-47154 'virtual void QSslSocketBackendPrivate::transmit() SSLRead failed ' - 'with: -9805', # noqa + 'with: -9805', # flake8: disable=E131 ] # Messages which will trigger an exception immediately diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index ab8925fb0..ecd31ae0f 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -563,7 +563,7 @@ def disabled_excepthook(): sys.excepthook = old_excepthook -class prevent_exceptions: # noqa # pylint: disable=invalid-name +class prevent_exceptions: # pylint: disable=invalid-name """Decorator to ignore and log exceptions. diff --git a/setup.cfg b/setup.cfg index d910dd19d..3d15facf7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,3 +10,10 @@ exclude = .venv,.hypothesis,.git,__pycache__,resources.py # N802: function name should be lowercase ignore = E128,E226,E265,E501,E402,E266,F401,N802 max-complexity = 12 +putty-ignore = + /# pylint: disable=invalid-name/ : +N801,N806 + /# pragma: no mccabe/ : +C901 + /# flake8: disable=E131/ : +E131 + /# flake8: disable=N803/ : +N803 + /# flake8: disable=T002/ : +T002 + /# flake8: disable=F841/ : +F841 diff --git a/tests/unit/utils/test_debug.py b/tests/unit/utils/test_debug.py index 4479df049..035bd3e08 100644 --- a/tests/unit/utils/test_debug.py +++ b/tests/unit/utils/test_debug.py @@ -247,8 +247,8 @@ class TestGetAllObjects: root = QObject() o1 = self.Object('Object 1', root) - o2 = self.Object('Object 2', o1) # noqa - o3 = self.Object('Object 3', root) # noqa + o2 = self.Object('Object 2', o1) # flake8: disable=F841 + o3 = self.Object('Object 3', root) # flake8: disable=F841 expected = textwrap.dedent(""" Qt widgets - 2 objects: diff --git a/tests/unit/utils/usertypes/test_enum.py b/tests/unit/utils/usertypes/test_enum.py index b708c0c8a..b78251171 100644 --- a/tests/unit/utils/usertypes/test_enum.py +++ b/tests/unit/utils/usertypes/test_enum.py @@ -44,7 +44,7 @@ def test_name(enum): def test_unknown(enum): """Test invalid values which should raise an AttributeError.""" with pytest.raises(AttributeError): - _ = enum.three # noqa + _ = enum.three # flake8: disable=F841 def test_start(): diff --git a/tox.ini b/tox.ini index 477da5ddc..91d29500b 100644 --- a/tox.ini +++ b/tox.ini @@ -155,6 +155,7 @@ deps = flake8==2.5.1 flake8-debugger==1.4.0 pep8-naming==0.3.3 + flake8-putty==0.2.0 mccabe==0.3.1 pep8==1.7.0 pyflakes==1.0.0