From 1fcab35b2bb6158837817414fe25e3c406f494d7 Mon Sep 17 00:00:00 2001 From: FUJIWARA Katsunori Date: Sun, 10 Nov 2019 20:05:22 +0900 Subject: [PATCH 1/6] Make flake8 ignore breaking line after binary operator This commit makes flake8 ignore "line break after binary operator" (W504), as same as blockdiag. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 68c5213..ca22a00 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,5 +18,5 @@ strict = 1 restructuredtext = 1 [flake8] -ignore=_ +ignore = W504 copyright-check = True From b27a7cb370e1efd4a1731dff0b36f346fbc88a32 Mon Sep 17 00:00:00 2001 From: FUJIWARA Katsunori Date: Sun, 10 Nov 2019 20:05:22 +0900 Subject: [PATCH 2/6] Specify exception type at except statement to avoid flake8 error This commit explicitly specifies exception type at "except" statement, in order to avoid flake8 error "do not use bare 'except'" (E722). --- src/rackdiag/elements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rackdiag/elements.py b/src/rackdiag/elements.py index d5dbce3..faeba5e 100644 --- a/src/rackdiag/elements.py +++ b/src/rackdiag/elements.py @@ -140,7 +140,7 @@ def get_linked_levels(self, level): def get_max_height(self, y): try: return max(n.colheight for n in self.items(y)) - except: + except Exception: return 0 height = get_max_height(self, level) From 91e211c66f23414a51cab6015d157c7c2923a6ef Mon Sep 17 00:00:00 2001 From: FUJIWARA Katsunori Date: Sun, 10 Nov 2019 20:05:22 +0900 Subject: [PATCH 3/6] Add 'r' prefix to string literals to avoid flake8 warning This commit adds 'r' prefix to string literals, which use invalid escape sequence ('\d', '\s', and '\.'), in order to avoid flake8 warning "invalid escape sequence" (W605). This changes should be safe enough, because none of 'r' prefixed string literals contain any valid escape sequence (e.g. '\n', '\\', and so on). --- src/nwdiag/elements.py | 2 +- src/nwdiag/tests/test_rst_directives.py | 12 ++++++------ src/packetdiag/tests/test_rst_directives.py | 12 ++++++------ src/rackdiag/elements.py | 8 ++++---- src/rackdiag/tests/test_rst_directives.py | 12 ++++++------ 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/nwdiag/elements.py b/src/nwdiag/elements.py index dead074..60ecc5b 100644 --- a/src/nwdiag/elements.py +++ b/src/nwdiag/elements.py @@ -36,7 +36,7 @@ def set_attributes(self, network, attrs=None): for attr in attrs: if attr.name == 'address': - address = re.sub('\s*,\s*', '\n', unquote(attr.value)) + address = re.sub(r'\s*,\s*', '\n', unquote(attr.value)) self.address[network] = address else: self.set_attribute(attr) diff --git a/src/nwdiag/tests/test_rst_directives.py b/src/nwdiag/tests/test_rst_directives.py index 2a66702..f61d00f 100644 --- a/src/nwdiag/tests/test_rst_directives.py +++ b/src/nwdiag/tests/test_rst_directives.py @@ -152,7 +152,7 @@ def test_setup_noviewbox_is_true(self): self.assertEqual(1, len(doctree)) self.assertEqual(nodes.image, type(doctree[0])) svg = open(doctree[0]['uri']).read() - self.assertRegexpMatches(svg, ' Date: Sun, 10 Nov 2019 20:05:22 +0900 Subject: [PATCH 4/6] Drop py26 support This dropping should be reasonable, because blockdiag already did so. This changes simplify subsequent changes for tox.ini. --- setup.py | 4 ---- tox.ini | 10 +--------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/setup.py b/setup.py index 21ead92..e4216a1 100644 --- a/setup.py +++ b/setup.py @@ -21,10 +21,6 @@ 'reportlab', 'docutils'] -# only for Python2.6 -if sys.version_info > (2, 6) and sys.version_info < (2, 7): - test_requires.append('unittest2') - if (3, 2) < sys.version_info < (3, 3): requires.append('webcolors < 1.5') # webcolors-1.5 does not support py32 diff --git a/tox.ini b/tox.ini index ed5f3de..11e2fad 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py26,py27,py32,py33,py34,blockdiag_dev +envlist=py27,py32,py33,py34,blockdiag_dev [testenv] deps= @@ -16,14 +16,6 @@ commands= flake8 src -[testenv:py26] -deps= - nose - flake8 - docutils - reportlab - unittest2 - [testenv:blockdiag_dev] deps= {[testenv]deps} From 20281a255730454fc27e2121f09691f4ec7af69f Mon Sep 17 00:00:00 2001 From: FUJIWARA Katsunori Date: Sun, 10 Nov 2019 20:05:22 +0900 Subject: [PATCH 5/6] Refactor dependency configuration for testing This commit follows dependency configuration style of blockdiag, as below: - list up dependencies for testing in setup.py instead of tox.ini, and specify "[testenv] extras" to install them before testing - enable "[testenv] usedevelop" without this, tox fails before testing because "docutils" is not available, if executed on plain environment. This commit still keeps empty "[testenv] deps", because this is referred by "[testenv:blockdiag_dev] deps". --- setup.py | 3 +++ tox.ini | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index e4216a1..a68ea5f 100644 --- a/setup.py +++ b/setup.py @@ -18,6 +18,9 @@ requires = ['blockdiag>=1.5.0'] test_requires = ['nose', 'pep8>=1.3', + 'flake8', + 'flake8-coding', + 'flake8-copyright', 'reportlab', 'docutils'] diff --git a/tox.ini b/tox.ini index 11e2fad..8360122 100644 --- a/tox.ini +++ b/tox.ini @@ -2,13 +2,12 @@ envlist=py27,py32,py33,py34,blockdiag_dev [testenv] +usedevelop = True +extras = + pdf + rst + testing deps= - nose - flake8 - flake8-coding - flake8-copyright - docutils - reportlab passenv= ALL_TESTS commands= From b112f242643a31812eb53f0f80d2fead123f5b34 Mon Sep 17 00:00:00 2001 From: FUJIWARA Katsunori Date: Sun, 10 Nov 2019 20:05:22 +0900 Subject: [PATCH 6/6] Change blockdiag repository reference from bitbucket to github --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 8360122..4963d66 100644 --- a/tox.ini +++ b/tox.ini @@ -18,4 +18,4 @@ commands= [testenv:blockdiag_dev] deps= {[testenv]deps} - hg+https://bitbucket.org/blockdiag/blockdiag + git+https://github.com/blockdiag/blockdiag.git