From 99cc701ea00614eeabaab7739a441cb7dc3f74c9 Mon Sep 17 00:00:00 2001 From: Alexander Loechel Date: Wed, 23 Aug 2017 17:57:28 +0200 Subject: [PATCH] apply @gforcada 's recommendations --- CHANGES.rst | 2 +- constrains.txt | 33 ++++++++++++++++++++++++++++++++ lib/diazo/runtrace.py | 2 +- lib/diazo/wsgi.py | 2 +- tox.ini | 44 ++++++++++++++++++++++++++++--------------- 5 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 constrains.txt diff --git a/CHANGES.rst b/CHANGES.rst index d22350b..5e1d95d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,7 @@ New features: Bug fixes: -- Code Cleanup and enforcing Code Convertions +- Code Cleanup and enforcing Code Conversions [loechel] diff --git a/constrains.txt b/constrains.txt new file mode 100644 index 0000000..d370d5a --- /dev/null +++ b/constrains.txt @@ -0,0 +1,33 @@ +configparser==3.5.0 +cssselect==1.0.1 +enum-compat==0.0.2 +enum34==1.1.6 +flake8==3.4.1 +flake8-blind-except==0.1.1 +flake8-coding==1.3.0 +flake8-commas==0.4.3 +flake8-debugger==1.4.0 +flake8-deprecated==1.2.1 +flake8-html==0.4.0 +flake8-isort==2.2.1 +flake8-pep3101==1.1 +flake8-polyfill==1.0.1 +flake8-print==2.0.2 +flake8-quotes==0.11.0 +flake8-strict==0.1.4 +flake8-string-format==0.2.3 +flake8-todo==0.7 +FormEncode==1.3.1 +future==0.16.0 +isort==4.2.15 +Jinja2==2.9.6 +lxml==3.8.0 +MarkupSafe==1.0 +mccabe==0.6.1 +pycodestyle==2.3.1 +pyflakes==1.5.0 +Pygments==2.2.0 +repoze.xmliter==0.6 +six==1.10.0 +testfixtures==5.1.1 +WebOb==1.7.3 diff --git a/lib/diazo/runtrace.py b/lib/diazo/runtrace.py index db84e0e..99822b9 100644 --- a/lib/diazo/runtrace.py +++ b/lib/diazo/runtrace.py @@ -87,7 +87,7 @@ def generate_debug_html( """Generate an HTML node with debug info""" def newElement(tag, content, **kwargs): n = etree.Element(tag, **kwargs) - if hasattr(content, 'tag'): + if getattr(content, 'tag', None): n.append(content) else: n.text = content diff --git a/lib/diazo/wsgi.py b/lib/diazo/wsgi.py index 0375890..02566a8 100644 --- a/lib/diazo/wsgi.py +++ b/lib/diazo/wsgi.py @@ -312,7 +312,7 @@ def __call__(self, environ, start_response): # Headers should be left intact return response(environ, start_response) finally: - if hasattr(response.app_iter, 'close'): + if getattr(response.app_iter, 'close', None): response.app_iter.close() self.reset_headers(response) diff --git a/tox.ini b/tox.ini index c839661..1088780 100644 --- a/tox.ini +++ b/tox.ini @@ -10,8 +10,8 @@ envlist = py35, py36, docs, - isort, - flake8 + lint-py2, + lint-py3, coverage-report, [testenv] @@ -28,6 +28,7 @@ setenv = COVERAGE_FILE=.coverage.{envname} deps = + -cconstrains.txt pdbpp pytest pytest-cov @@ -40,13 +41,15 @@ whitelist_externals = [testenv:coverage-report] basepython = python2.7 -deps = coverage +skip_install = true + +deps = + -cconstrains.txt + coverage setenv = COVERAGE_FILE=.coverage -skip_install = true - commands = coverage erase coverage combine @@ -54,22 +57,18 @@ commands = coverage html coverage xml -[testenv:isort] -basepython = python2.7 -deps = isort -commands = - #isort --check-only --recursive {toxinidir}/lib - isort --check-only --recursive {toxinidir}/lib - [testenv:isort-apply] basepython = python2.7 +skip_install = true deps = isort commands = isort --apply --recursive {toxinidir}/lib -[testenv:flake8] -basepython = python2.7 +[lint] +skip_install = true + deps = + -cconstrains.txt flake8 # helper to generate HTML reports: flake8-html @@ -81,29 +80,43 @@ deps = flake8-isort flake8-pep3101 # flake8-plone-api -# flake8-plone-hasattr + flake8-plone-hasattr flake8-print flake8-quotes flake8-string-format flake8-todo flake8_strict + isort commands = mkdir -p {toxinidir}/reports/flake8 + #isort --check-only --recursive {toxinidir}/src #- flake8 --format=html --htmldir={toxinidir}/reports/flake8 --doctests src tests setup.py #flake8 src tests setup.py --doctests + isort --check-only --recursive {toxinidir}/lib - flake8 --format=html --htmldir={toxinidir}/reports/flake8 --doctests lib setup.py flake8 lib setup.py --doctests whitelist_externals = mkdir +[testenv:lint-py2] +basepython = python2 +deps = {[lint]deps} +commands = {[lint]commands} + +[testenv:lint-py3] +basepython = python3 +deps = {[lint]deps} +commands = {[lint]commands} + [testenv:docs] basepython = python2.7 commands = sphinx-build -b html -d build/docs/doctrees docs build/docs/html #sphinx-build -b doctest docs build/docs/doctrees deps = + -cconstrains.txt Sphinx [testenv:release] @@ -111,6 +124,7 @@ skip_install = true basepython = python2.7 deps = + -cconstrains.txt zest.releaser[recommended] commands =