diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 29d9c8be4..000000000 --- a/.flake8 +++ /dev/null @@ -1,13 +0,0 @@ -# vim: ft=dosini fileencoding=utf-8: - -[flake8] -# E265: Block comment should start with '#' -# E501: Line too long -# F841: unused variable -# F401: Unused import -# E402: module level import not at top of file -# E266: too many leading '#' for block comment -# W503: line break before binary operator -ignore=E265,E501,F841,F401,E402,E266,W503 -max_complexity = 12 -exclude=resources.py diff --git a/.gitignore b/.gitignore index f3ff3652a..a4c699d38 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ __pycache__ /htmlcov /.tox /testresults.html +/.cache diff --git a/CONTRIBUTING.asciidoc b/CONTRIBUTING.asciidoc index 7b0fe6087..ed76f5152 100644 --- a/CONTRIBUTING.asciidoc +++ b/CONTRIBUTING.asciidoc @@ -93,7 +93,9 @@ Currently, the following tools will be invoked when you run `tox`: * Unit tests using the Python https://docs.python.org/3.4/library/unittest.html[unittest] framework -* https://pypi.python.org/pypi/flake8/[flake8] +* https://pypi.python.org/pypi/pyflakes[pyflakes] via https://pypi.python.org/pypi/pytest-flakes[pytest-flakes] +* https://pypi.python.org/pypi/pep8[pep8] via https://pypi.python.org/pypi/pytest-pep8[pytest-pep8] +* https://pypi.python.org/pypi/mccabe[mccabe] via https://pypi.python.org/pypi/pytest-mccabe[pytest-mccabe] * https://github.com/GreenSteam/pep257/[pep257] * http://pylint.org/[pylint] * https://pypi.python.org/pypi/pyroma/[pyroma] diff --git a/MANIFEST.in b/MANIFEST.in index 7ecd44de2..4092f81c5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -28,7 +28,6 @@ include doc/qutebrowser.1.asciidoc prune tests exclude qutebrowser.rcc exclude .coveragerc -exclude .flake8 exclude .pylintrc exclude .eslintrc exclude doc/help diff --git a/qutebrowser/app.py b/qutebrowser/app.py index d125d1d1a..2e8f7ea6a 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -606,7 +606,7 @@ class Quitter: # event loop, so we can shut down immediately. self._shutdown(status) - def _shutdown(self, status): # noqa + def _shutdown(self, status): """Second stage of shutdown.""" log.destroy.debug("Stage 2 of shutting down...") if qApp is None: diff --git a/qutebrowser/browser/network/networkmanager.py b/qutebrowser/browser/network/networkmanager.py index 3b4c71ed0..a3fc76baf 100644 --- a/qutebrowser/browser/network/networkmanager.py +++ b/qutebrowser/browser/network/networkmanager.py @@ -181,7 +181,7 @@ class NetworkManager(QNetworkAccessManager): request.deleteLater() self.shutting_down.emit() - if SSL_AVAILABLE: # noqa + if SSL_AVAILABLE: # pragma: no mccabe @pyqtSlot('QNetworkReply*', 'QList') def on_ssl_errors(self, reply, errors): """Decide if SSL errors should be ignored or not. diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index d55597d9d..4bda15f8a 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -420,7 +420,7 @@ class Command: value = self._type_conv[param.name](value) return name, value - def _get_call_args(self, win_id): # noqa + def _get_call_args(self, win_id): """Get arguments for a function call. Args: diff --git a/qutebrowser/misc/crashsignal.py b/qutebrowser/misc/crashsignal.py index 7598f3312..2e336bc1e 100644 --- a/qutebrowser/misc/crashsignal.py +++ b/qutebrowser/misc/crashsignal.py @@ -190,7 +190,7 @@ class CrashHandler(QObject): objects = "" return ExceptionInfo(pages, cmd_history, objects) - def exception_hook(self, exctype, excvalue, tb): # noqa + def exception_hook(self, exctype, excvalue, tb): """Handle uncaught python exceptions. It'll try very hard to write all open tabs to a file, and then exit diff --git a/qutebrowser/misc/split.py b/qutebrowser/misc/split.py index b763d8246..a7bbeea6e 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/tox.ini b/tox.ini index f39af4ee3..0b14e4e74 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = unittests,misc,pep257,flake8,pylint,pyroma,check-manifest +envlist = unittests,misc,pep257,pyflakes,pep8,mccabe,pylint,pyroma,check-manifest [testenv] basepython = python3 @@ -74,16 +74,40 @@ passenv = LANG # D402: First line should not be function's signature (false-positives) commands = {envpython} -m pep257 scripts tests qutebrowser --ignore=D102,D103,D209,D402 '--match=(?!resources|test_content_disposition).*\.py' -[testenv:flake8] -skip_install = true +[testenv:pyflakes] +# https://github.com/fschulze/pytest-flakes/issues/6 +setenv = LANG=en_US.UTF-8 deps = -r{toxinidir}/requirements.txt - pyflakes==0.8.1 - pep8==1.5.7 # rq.filter: <1.6.0 - flake8==2.4.0 + py==1.4.27 + pytest==2.7.1 + pyflakes==0.9.0 + pytest-flakes==0.2 commands = {[testenv:mkvenv]commands} - {envdir}/bin/flake8 scripts tests qutebrowser --config=.flake8 + {envpython} -m py.test -q --flakes -m flakes + +[testenv:pep8] +deps = + -r{toxinidir}/requirements.txt + py==1.4.27 + pytest==2.7.1 + pep8==1.6.2 + pytest-pep8==1.0.6 +commands = + {[testenv:mkvenv]commands} + {envpython} -m py.test -q --pep8 -m pep8 + +[testenv:mccabe] +deps = + -r{toxinidir}/requirements.txt + py==1.4.27 + pytest==2.7.1 + mccabe==0.3 + pytest-mccabe==0.1 +commands = + {[testenv:mkvenv]commands} + {envpython} -m py.test -q --mccabe -m mccabe [testenv:pyroma] skip_install = true @@ -129,3 +153,15 @@ commands = norecursedirs = .tox .venv markers = gui: Tests using the GUI (e.g. spawning widgets) +flakes-ignore = + UnusedImport + UnusedVariable + resources.py ALL +pep8ignore = + E265 # Block comment should start with '#' + E501 # Line too long + E402 # module level import not at top of file + E266 # too many leading '#' for block comment + W503 # line break before binary operator + resources.py ALL +mccabe-complexity = 12