From 5311576c3446efe75c216bffe7cf024583298841 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 10 Feb 2016 19:18:47 +0100 Subject: [PATCH] Check pep257 via flake8. We'll still keep the pydocstyle environment though until flake8-pep257 adds support for that: https://github.com/Robpol86/flake8-pep257/issues/6 --- setup.cfg | 14 +++++++++++++- setup.py | 2 +- .../unit/browser/http/test_content_disposition.py | 9 +++++---- tests/unit/browser/test_cache.py | 2 +- tests/unit/browser/test_cookies.py | 5 +++-- tests/unit/browser/test_pdfjs.py | 2 +- tests/unit/browser/test_webelem.py | 2 +- tests/unit/completion/test_column_widths.py | 8 ++++---- tests/unit/config/test_configtypes.py | 2 +- tests/unit/keyinput/test_basekeyparser.py | 2 +- tests/unit/misc/test_autoupdate.py | 3 ++- tests/unit/misc/test_cmdhistory.py | 8 ++++---- tests/unit/misc/test_ipc.py | 4 ++-- tests/unit/misc/test_sessions.py | 1 - tests/unit/utils/test_urlutils.py | 9 +++------ tox.ini | 2 ++ 16 files changed, 44 insertions(+), 31 deletions(-) diff --git a/setup.cfg b/setup.cfg index 121f21bf2..307403556 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,13 +23,22 @@ exclude = .venv,.hypothesis,.git,__pycache__,resources.py # P102: docstring does contain unindexed parameters # P103: other string does contain unindexed parameters # D001: found assert_ replace it with assertTrue +# D102: Missing docstring in public method (will be handled by others) +# D103: Missing docstring in public function (will be handled by others) +# D104: Missing docstring in public package (will be handled by others) +# D105: Missing docstring in magic method (will be handled by others) +# D209: Blank line before closing """ (removed from PEP257) +# D211: No blank lines allowed before class docstring +# (PEP257 got changed, but let's stick to the old standard) +# D402: First line should not be function's signature (false-positives) ignore = E128,E226,E265,E501,E402,E266, F401, N802, L101,L102,L103,L201,L202,L203,L204,L207,L302, P101,P102,P103, - D001 + D001, + D102,D103,D104,D105,D209,D211,D402 max-complexity = 12 putty-ignore = /# pylint: disable=invalid-name/ : +N801,N806 @@ -40,6 +49,9 @@ putty-ignore = /# flake8: disable=T002/ : +T002 /# flake8: disable=F841/ : +F841 /# flake8: disable=S001/ : +S001 + tests/*/*/test_*.py : +D100,D101,D401 + tests/*/test_*.py : +D100,D101,D401 + tests/unit/browser/http/test_content_disposition.py : +D400 copyright-check = True copyright-regexp = # Copyright [\d-]+ .* copyright-min-file-size = 110 diff --git a/setup.py b/setup.py index 1cb99e8ab..6e594af12 100755 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""setuptools installer script for qutebrowser""" +"""setuptools installer script for qutebrowser.""" import os import os.path diff --git a/tests/unit/browser/http/test_content_disposition.py b/tests/unit/browser/http/test_content_disposition.py index 06da00118..c845e3ef9 100644 --- a/tests/unit/browser/http/test_content_disposition.py +++ b/tests/unit/browser/http/test_content_disposition.py @@ -383,10 +383,11 @@ class TestAttachment: 'foo-%41.html') def test_attwithnamepct(self, header_checker): - """'attachment', specifying a name parameter of foo-%41.html. (this - test was added to observe the behavior of the (unspecified) treatment - of "name" as synonym for "filename"; see Ned Freed's summary[1] where - this comes from in MIME messages) + """'attachment', specifying a name parameter of foo-%41.html. + + (This test was added to observe the behavior of the (unspecified) + treatment of "name" as synonym for "filename"; see Ned Freed's + summary[1] where this comes from in MIME messages) Should be treated as extension parameter, therefore almost any behavior is acceptable. diff --git a/tests/unit/browser/test_cache.py b/tests/unit/browser/test_cache.py index de37f764a..ae59604a3 100644 --- a/tests/unit/browser/test_cache.py +++ b/tests/unit/browser/test_cache.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""Tests for qutebrowser.browser.cache""" +"""Tests for qutebrowser.browser.cache.""" from PyQt5.QtCore import QUrl, QDateTime from PyQt5.QtNetwork import QNetworkDiskCache, QNetworkCacheMetaData diff --git a/tests/unit/browser/test_cookies.py b/tests/unit/browser/test_cookies.py index eb60a55dc..ba5fbe810 100644 --- a/tests/unit/browser/test_cookies.py +++ b/tests/unit/browser/test_cookies.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""Tests for qutebrowser.browser.cookies""" +"""Tests for qutebrowser.browser.cookies.""" from unittest import mock @@ -41,7 +41,8 @@ EXPIRED_COOKIE = b'foo4=bar; expires=Sat, 01-Jan-2000 08:00:01 GMT' class LineparserSaveStub(lineparser.BaseLineParser): - """A stub for LineParser's save() + + """A stub for LineParser's save(). Attributes: data: The data before the write diff --git a/tests/unit/browser/test_pdfjs.py b/tests/unit/browser/test_pdfjs.py index f3bf0413f..606c480eb 100644 --- a/tests/unit/browser/test_pdfjs.py +++ b/tests/unit/browser/test_pdfjs.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""Tests for qutebrowser.browser.pdfjs""" +"""Tests for qutebrowser.browser.pdfjs.""" import textwrap diff --git a/tests/unit/browser/test_webelem.py b/tests/unit/browser/test_webelem.py index f36b16694..1457e08ef 100644 --- a/tests/unit/browser/test_webelem.py +++ b/tests/unit/browser/test_webelem.py @@ -468,7 +468,7 @@ class TestIsVisibleIframe: @pytest.fixture def invalid_objects(self, stubs): - """Set up the following base situation: + """Set up the following base situation. 0, 0 300, 0 ############################## diff --git a/tests/unit/completion/test_column_widths.py b/tests/unit/completion/test_column_widths.py index 8be80b2e6..d138e996b 100644 --- a/tests/unit/completion/test_column_widths.py +++ b/tests/unit/completion/test_column_widths.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""Tests for qutebrowser.completion.models column widths""" +"""Tests for qutebrowser.completion.models column widths.""" import pytest @@ -33,7 +33,7 @@ from qutebrowser.completion.models.urlmodel import UrlCompletionModel class TestColumnWidths: - """Tests for the column widths of the completion models""" + """Tests for the column widths of the completion models.""" CLASSES = [BaseCompletionModel, SettingOptionCompletionModel, SettingOptionCompletionModel, SettingSectionCompletionModel, @@ -44,10 +44,10 @@ class TestColumnWidths: @pytest.mark.parametrize("model", CLASSES) def test_list_size(self, model): - """Test if there are 3 items in the COLUMN_WIDTHS property""" + """Test if there are 3 items in the COLUMN_WIDTHS property.""" assert len(model.COLUMN_WIDTHS) == 3 @pytest.mark.parametrize("model", CLASSES) def test_column_width_sum(self, model): - """Test if the sum of the widths asserts to 100""" + """Test if the sum of the widths asserts to 100.""" assert sum(model.COLUMN_WIDTHS) == 100 diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py index 85f60ce9c..b555ad544 100644 --- a/tests/unit/config/test_configtypes.py +++ b/tests/unit/config/test_configtypes.py @@ -411,7 +411,7 @@ class TestFlagList: @pytest.fixture def klass_valid_none(self): - """Return a FlagList with valid_values = None""" + """Return a FlagList with valid_values = None.""" return configtypes.FlagList @pytest.mark.parametrize('val', ['', 'foo', 'foo,bar', 'foo,']) diff --git a/tests/unit/keyinput/test_basekeyparser.py b/tests/unit/keyinput/test_basekeyparser.py index de7acaab3..40ab6184f 100644 --- a/tests/unit/keyinput/test_basekeyparser.py +++ b/tests/unit/keyinput/test_basekeyparser.py @@ -331,7 +331,7 @@ class TestCount: def test_clear_keystring(qtbot, keyparser): - """Test that the keystring is cleared and the signal is emitted""" + """Test that the keystring is cleared and the signal is emitted.""" keyparser._keystring = 'test' with qtbot.waitSignal(keyparser.keystring_updated): keyparser.clear_keystring() diff --git a/tests/unit/misc/test_autoupdate.py b/tests/unit/misc/test_autoupdate.py index 4b8750624..eb7ed6f91 100644 --- a/tests/unit/misc/test_autoupdate.py +++ b/tests/unit/misc/test_autoupdate.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""Tests for qutebrowser.misc.autoupdate""" +"""Tests for qutebrowser.misc.autoupdate.""" import pytest from PyQt5.QtCore import QUrl @@ -28,6 +28,7 @@ INVALID_JSON = ['{"invalid": { "json"}', '{"wrong": "keys"}'] class HTTPGetStub(httpclient.HTTPClient): + """A stub class for HTTPClient. Attributes: diff --git a/tests/unit/misc/test_cmdhistory.py b/tests/unit/misc/test_cmdhistory.py index 75f9f2d2f..47284c075 100644 --- a/tests/unit/misc/test_cmdhistory.py +++ b/tests/unit/misc/test_cmdhistory.py @@ -97,7 +97,7 @@ def test_setitem(hist): def test_not_browsing_error(hist): - """Test that next/previtem throws a ValueError""" + """Test that next/previtem throws a ValueError.""" with pytest.raises(ValueError) as error1: hist.nextitem() assert str(error1.value) == "Currently not browsing history" @@ -122,7 +122,7 @@ def test_previtem_single(hist, monkeypatch): def test_nextitem_previtem_chain(hist): - """Test a combination of nextitem and previtem statements""" + """Test a combination of nextitem and previtem statements.""" assert hist.start('f') == 'fifth' assert hist.previtem() == 'fourth' assert hist.previtem() == 'first' @@ -130,14 +130,14 @@ def test_nextitem_previtem_chain(hist): def test_nextitem_index_error(hist): - """"Test nextitem() when _tmphist raises an IndexError""" + """"Test nextitem() when _tmphist raises an IndexError.""" hist.start('f') with pytest.raises(cmdhistory.HistoryEndReachedError): hist.nextitem() def test_previtem_index_error(hist): - """"Test previtem() when _tmphist raises an IndexError""" + """"Test previtem() when _tmphist raises an IndexError.""" hist.start('f') with pytest.raises(cmdhistory.HistoryEndReachedError): for _ in range(10): diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index b6611d8e1..e71bd4105 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -734,7 +734,7 @@ class TestSendOrListen: def test_address_in_use_ok(self, qlocalserver_mock, qlocalsocket_mock, stubs, caplog, args): - """Test the following scenario: + """Test the following scenario. - First call to send_to_running_instance: -> could not connect (server not found) @@ -770,7 +770,7 @@ class TestSendOrListen: def test_address_in_use_error(self, qlocalserver_mock, qlocalsocket_mock, stubs, caplog, args, has_error, exc_name, exc_msg): - """Test the following scenario: + """Test the following scenario. - First call to send_to_running_instance: -> could not connect (server not found) diff --git a/tests/unit/misc/test_sessions.py b/tests/unit/misc/test_sessions.py index a688ef0d4..8517e0db9 100644 --- a/tests/unit/misc/test_sessions.py +++ b/tests/unit/misc/test_sessions.py @@ -244,7 +244,6 @@ class TestSaveTab: @pytest.mark.parametrize('factor', [-1.0, 0.0, 1.5]) def test_zoom(self, hist_tester, factor): """Test zoom.""" - items = [ Item(url=QUrl('http://www.example.com/'), title='Test title', active=True), diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py index 84936be4f..bb2778765 100644 --- a/tests/unit/utils/test_urlutils.py +++ b/tests/unit/utils/test_urlutils.py @@ -555,7 +555,6 @@ def test_same_domain_invalid_url(url1, url2): 'http://foo.bar/?header=text/pl%C3%A4in'), ]) def test_encoded_url(url, expected): - """Test encoded_url""" url = QUrl(url) assert urlutils.encoded_url(url) == expected @@ -636,8 +635,7 @@ class TestIncDecNumber: urlutils.incdec_number(QUrl(url), "increment") def test_number_below_0(self): - """Test incdec_number with a number that would be below zero - after decrementing.""" + """Test incdec_number with a number <0 after decrementing.""" with pytest.raises(urlutils.IncDecError): urlutils.incdec_number(QUrl('http://example.com/page_0.html'), 'decrement') @@ -648,14 +646,13 @@ class TestIncDecNumber: urlutils.incdec_number(QUrl(""), "increment") def test_wrong_mode(self): - """Test if incdec_number rejects a wrong parameter for the incdec - argument.""" + """Test if incdec_number rejects a wrong parameter for incdec.""" valid_url = QUrl("http://example.com/0") with pytest.raises(ValueError): urlutils.incdec_number(valid_url, "foobar") def test_wrong_segment(self): - """Test if incdec_number rejects a wrong segment""" + """Test if incdec_number rejects a wrong segment.""" with pytest.raises(urlutils.IncDecError): urlutils.incdec_number(QUrl('http://example.com'), 'increment', segments={'foobar'}) diff --git a/tox.ini b/tox.ini index d5adcb9d6..9a63dfc45 100644 --- a/tox.ini +++ b/tox.ini @@ -176,6 +176,8 @@ deps = flake8-deprecated==0.2 flake8-mock==0.2 flake8-pep3101==0.2 + flake8-pep257==1.0.5 + pep257==0.7.0 commands = {envpython} -m flake8