update flake8 and flake8-deprecated

Updated requirements and adjusted the configuration in `.flake8`; other
files have been modified where the lack of per-file auto-ignore caused
problems, where putty's `# flake8: disable=` syntax could be replaced
with a simpler `noqa`, or where pylint directives already suppressed the
same error.
This commit is contained in:
Ryan Farley 2017-11-24 09:25:01 -06:00
parent 03a9cbdfb4
commit 5ed8019115
22 changed files with 34 additions and 49 deletions

18
.flake8
View File

@ -33,18 +33,12 @@ ignore =
D102,D103,D104,D105,D209,D211,D402,D403
min-version = 3.4.0
max-complexity = 12
putty-auto-ignore = True
putty-ignore =
/# pylint: disable=invalid-name/ : +N801,N806
/# pragma: no mccabe/ : +C901
tests/*/test_*.py : +D100,D101,D401
tests/conftest.py : +F403
tests/unit/browser/test_history.py : +N806
tests/helpers/fixtures.py : +N806
tests/unit/browser/webkit/http/test_content_disposition.py : +D400
scripts/dev/ci/appveyor_install.py : +FI53
# FIXME:conf
tests/unit/completion/test_models.py : +F821
per-file-ignores =
tests/*/test_*.py : D100,D101,D401
tests/unit/browser/test_history.py : N806
tests/helpers/fixtures.py : N806
tests/unit/browser/webkit/http/test_content_disposition.py : D400
scripts/dev/ci/appveyor_install.py : FI53
copyright-check = True
copyright-regexp = # Copyright [\d-]+ .*
copyright-min-file-size = 110

View File

@ -1,23 +1,21 @@
# This file is automatically generated by scripts/dev/recompile_requirements.py
flake8==2.6.2 # rq.filter: < 3.0.0
flake8==3.5.0
flake8-copyright==0.2.0
flake8-debugger==3.0.0
flake8-deprecated==1.2.1 # rq.filter: < 1.3
flake8-deprecated==1.3
flake8-docstrings==1.0.3 # rq.filter: < 1.1.0
flake8-future-import==0.4.3
flake8-mock==0.3
flake8-pep3101==1.0 # rq.filter: < 1.1
flake8-per-file-ignores==0.4
flake8-polyfill==1.0.1
flake8-putty==0.4.0
flake8-string-format==0.2.3
flake8-tidy-imports==1.1.0
flake8-tuple==0.2.13
mccabe==0.6.1
packaging==16.8
pep8-naming==0.4.1
pycodestyle==2.3.1
pydocstyle==1.1.1 # rq.filter: < 2.0.0
pyflakes==1.6.0
pyparsing==2.2.0
six==1.11.0

View File

@ -1,12 +1,12 @@
flake8<3.0.0
flake8
flake8-copyright
flake8-debugger
flake8-deprecated<1.3
flake8-deprecated
flake8-docstrings<1.1.0
flake8-future-import
flake8-mock
flake8-pep3101<1.1
flake8-putty
flake8-per-file-ignores
flake8-string-format
flake8-tidy-imports
flake8-tuple
@ -14,14 +14,7 @@ pep8-naming
pydocstyle<2.0.0
pyflakes
# Pinned to 2.0.0 otherwise
pycodestyle==2.3.1
# Pinned to 0.5.3 otherwise
mccabe==0.6.1
# Waiting until flake8-putty updated
#@ filter: flake8 < 3.0.0
#@ filter: pydocstyle < 2.0.0
#@ filter: flake8-docstrings < 1.1.0
#@ filter: flake8-pep3101 < 1.1
#@ filter: flake8-deprecated < 1.3

View File

@ -91,7 +91,7 @@ class Redirect(Exception):
self.url = url
class add_handler: # pylint: disable=invalid-name
class add_handler: # noqa: N801,N806 pylint: disable=invalid-name
"""Decorator to register a qute://* URL handler.

View File

@ -206,7 +206,7 @@ class NetworkManager(QNetworkAccessManager):
# No @pyqtSlot here, see
# https://github.com/qutebrowser/qutebrowser/issues/2213
def on_ssl_errors(self, reply, errors): # pragma: no mccabe
def on_ssl_errors(self, reply, errors): # noqa: C901 pragma: no mccabe
"""Decide if SSL errors should be ignored or not.
This slot is called on SSL/TLS errors by the self.sslErrors signal.

View File

@ -34,7 +34,7 @@ class FixedDataNetworkReply(QNetworkReply):
"""QNetworkReply subclass for fixed data."""
def __init__(self, request, fileData, mimeType, # flake8: disable=N803
def __init__(self, request, fileData, mimeType, # noqa: N803
parent=None):
"""Constructor.

View File

@ -61,7 +61,7 @@ def check_exclusive(flags, names):
argstr))
class register: # pylint: disable=invalid-name
class register: # noqa: N801,N806 pylint: disable=invalid-name
"""Decorator to register a new command handler.
@ -114,7 +114,7 @@ class register: # pylint: disable=invalid-name
return func
class argument: # pylint: disable=invalid-name
class argument: # noqa: N801,N806 pylint: disable=invalid-name
"""Decorator to customize an argument for @cmdutils.register.

View File

@ -393,7 +393,7 @@ class Command:
if isinstance(typ, tuple):
raise TypeError("{}: Legacy tuple type annotation!".format(
self.name))
elif type(typ) is type(typing.Union): # flake8: disable=E721
elif type(typ) is type(typing.Union): # noqa: E721
# this is... slightly evil, I know
# We also can't use isinstance here because typing.Union doesn't
# support that.

View File

@ -38,7 +38,7 @@ key_instance = None
change_filters = []
class change_filter: # pylint: disable=invalid-name
class change_filter: # noqa: N801,N806 pylint: disable=invalid-name
"""Decorator to filter calls based on a config section/option matching.

View File

@ -62,7 +62,7 @@ class NotInModeError(Exception):
def init(win_id, parent):
"""Initialize the mode manager and the keyparsers for the given win_id."""
KM = usertypes.KeyMode # pylint: disable=invalid-name
KM = usertypes.KeyMode # noqa: N801,N806 pylint: disable=invalid-name
modeman = ModeManager(win_id, parent)
objreg.register('mode-manager', modeman, scope='window', window=win_id)
keyparsers = {

View File

@ -113,7 +113,7 @@ def _generate_stylesheet():
color: {{ conf.colors.%s }};
background-color: {{ conf.colors.%s }};
}
""" % (flag, flag, flag, # flake8: disable=S001
""" % (flag, flag, flag, # noqa: S001
option + '.fg', option + '.bg')
return stylesheet

View File

@ -22,7 +22,7 @@
import os
import sys
import bdb
import pdb # flake8: disable=T002
import pdb # noqa: T002
import signal
import functools
import faulthandler

View File

@ -55,7 +55,7 @@ class ShellLexer:
self.token = ''
self.state = ' '
def __iter__(self): # pragma: no mccabe
def __iter__(self): # noqa: C901 pragma: no mccabe
"""Read a raw token from the input stream."""
self.reset()
for nextchar in self.string:

View File

@ -232,7 +232,7 @@ def format_call(func, args=None, kwargs=None, full=True):
return '{}({})'.format(name, format_args(args, kwargs))
class log_time: # pylint: disable=invalid-name
class log_time: # noqa: N801,N806 pylint: disable=invalid-name
"""Log the time an operation takes.

View File

@ -360,7 +360,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', # flake8: disable=E131
'been edited', # noqa: E131
'libpng warning: iCCP: known incorrect sRGB profile',
# Hopefully harmless warning
'OpenType support missing for script ',
@ -419,7 +419,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', # flake8: disable=E131
'with: -9805', # noqa: E131
]
if any(msg.strip().startswith(pattern) for pattern in suppressed_msgs):

View File

@ -584,7 +584,7 @@ def disabled_excepthook():
sys.excepthook = old_excepthook
class prevent_exceptions: # pylint: disable=invalid-name
class prevent_exceptions: # noqa: N801,N806 pylint: disable=invalid-name
"""Decorator to ignore and log exceptions.

View File

@ -35,7 +35,7 @@ pytest.register_assert_rewrite('helpers')
from helpers import logfail
from helpers.logfail import fail_on_logging
from helpers.messagemock import message_mock
from helpers.fixtures import *
from helpers.fixtures import * # noqa: F403
from qutebrowser.utils import qtutils, standarddir, usertypes, utils
from qutebrowser.misc import objects

View File

@ -17,7 +17,7 @@
# 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=invalid-name
# noqa: N801,N806 pylint: disable=invalid-name
"""pytest fixtures used by the whole testsuite.

View File

@ -17,7 +17,7 @@
# 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=invalid-name,abstract-method
# noqa: N801,N806 pylint: disable=invalid-name,abstract-method
"""Fake objects/stubs."""

View File

@ -103,7 +103,7 @@ class TestRegister:
def test_lowercasing(self):
"""Make sure the function name is normalized correctly (uppercase)."""
@cmdutils.register()
def Test(): # pylint: disable=invalid-name
def Test(): # noqa: N801,N806 pylint: disable=invalid-name
"""Blah."""
pass

View File

@ -591,7 +591,7 @@ class StyleObj(QObject):
def __init__(self, stylesheet=None, parent=None):
super().__init__(parent)
if stylesheet is not None:
self.STYLESHEET = stylesheet # pylint: disable=invalid-name
self.STYLESHEET = stylesheet # noqa: N801,N806 pylint: disable=invalid-name
self.rendered_stylesheet = None
def setStyleSheet(self, stylesheet):

View File

@ -252,8 +252,8 @@ class TestGetAllObjects:
root = QObject()
o1 = self.Object('Object 1', root)
o2 = self.Object('Object 2', o1) # flake8: disable=F841
o3 = self.Object('Object 3', root) # flake8: disable=F841
o2 = self.Object('Object 2', o1) # noqa: F841
o3 = self.Object('Object 3', root) # noqa: F841
expected = textwrap.dedent("""
Qt widgets - 2 objects: