Skip to content

Commit bfff6f0

Browse files
committed
Fixed several bugs reported by linter (flake8)
Signed-off-by: Sorin Sbarnea <[email protected]>
1 parent 0929630 commit bfff6f0

16 files changed

+302
-203
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ dist
55
.tox
66
~*.*
77
build/
8-
.idea/inspectionProfiles/
8+
.idea/
99
.python-version
1010
.vscode
11+
/.idea/misc.xml
12+
/.idea/modules.xml
13+
/.cache
14+
/.eggs

.idea/misc.xml

-17
This file was deleted.

.idea/modules.xml

-8
This file was deleted.

.travis.yml

+81-55
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,100 @@
11
language: python
22
sudo: false
3+
matrix:
4+
fast_finish: false
35
os:
46
- linux
57
python:
68
- '2.7'
79
- '3.4'
810
- '3.5'
911
install:
10-
- pip -q install -r requirements.txt
11-
- pip -q install -r requirements-dev.txt
12+
- pip -q --log dist/pip.log install --upgrade pip setuptools py
13+
- pip -q --log dist/pip.log install -r requirements.txt -r requirements-dev.txt
14+
- pip check
1215
script:
13-
- curl --silent -Lo travis_after_all.py https://raw.github.com/pycontribs/travis_after_all/master/travis_after_all.py && travis_wait python setup.py prerelease test
14-
- export PACKAGE_VERSION=$(python -c "from wstools.version import __version__; print(__version__)")
16+
- travis_wait python setup.py test
17+
- export PACKAGE_NAME=$(python setup.py --name)
18+
- export PACKAGE_VERSION=$(python setup.py --version)
1519
after_success:
16-
- python travis_after_all.py
17-
- export $(cat .to_export_back)
18-
- |
19-
if [ "$BUILD_LEADER" = "YES" ]; then
20-
if [ "$BUILD_AGGREGATE_STATUS" = "others_succeeded" ]; then
21-
echo "All jobs succeeded! PUBLISHING..."
22-
else
23-
echo "Some jobs failed"
24-
fi
25-
fi
26-
- coveralls
27-
- python setup.py sdist bdist_wheel
20+
- python travis_after_all.py
21+
- export $(cat .to_export_back)
22+
- |
23+
if [ "$BUILD_LEADER" = "YES" ]; then
24+
if [ "$BUILD_AGGREGATE_STATUS" = "others_succeeded" ]; then
25+
echo "All jobs succeeded! PUBLISHING..."
26+
else
27+
echo "Some jobs failed"
28+
fi
29+
fi
30+
- coveralls
31+
- travis_wait python setup.py sdist bdist_wheel
2832
after_failure:
29-
- python travis_after_all.py
30-
- export $(cat .to_export_back)
31-
- |
32-
if [ "$BUILD_LEADER" = "YES" ]; then
33-
if [ "$BUILD_AGGREGATE_STATUS" = "others_failed" ]; then
34-
echo "All jobs failed"
35-
else
36-
echo "Some jobs failed"
37-
fi
38-
fi
33+
- python travis_after_all.py
34+
- export $(cat .to_export_back)
35+
- |
36+
if [ "$BUILD_LEADER" = "YES" ]; then
37+
if [ "$BUILD_AGGREGATE_STATUS" = "others_failed" ]; then
38+
echo "All jobs failed"
39+
else
40+
echo "Some jobs failed"
41+
fi
42+
fi
3943
after_script:
40-
- echo leader=$BUILD_LEADER status=$BUILD_AGGREGATE_STATUS
44+
- echo leader=$BUILD_LEADER status=$BUILD_AGGREGATE_STATUS
4145
branches:
4246
only:
4347
- master
4448
- develop
49+
notifications:
50+
email:
51+
4552
before_deploy:
46-
- echo "before deploy..."
53+
- echo "before deploy..."
4754
deploy:
48-
- provider: releases
49-
api_key:
50-
- secure: "gr9iOcQjdoAyUAim6FWKzJI9MBaJo9XKfGQGu7wdPXUFhg80Rp6GLJsowP+aU94NjXM1UQlVHDAy627WtjBlLH2SvmVEIIr7+UKBopBYuXG5jJ1m3wOZE+4f1Pqe9bqFc1DxgucqE8qF0sC24fIbNM2ToeyYrxrS6RoL2gRrX2I="
51-
file: "dist/wstools-$PACKAGE_VERSION.tar.gz"
52-
skip_cleanup: true
53-
on:
54-
branch: master
55-
condition: "$BUILD_LEADER = YES"
56-
tags: true
57-
- provider: pypi
58-
user: sorin
59-
password:
60-
secure: "E0cjANF7SLBdYrsnWLK8X/xWznqkF0JrP/DVfDazPzUYH6ynFeneyofzNJQPLTLsqe1eKXhuUJ/Sbl+RHFB0ySo/j/7NfYd/9pm8hpUkGCvR09IwtvMLgWKp3k10NWab03o2GOkSJSrLvZofyZBGR40wwu2O9uXPCb2rvucCGbw="
61-
distributions: "sdist bdist_wheel"
62-
on:
63-
branch: master
64-
condition: "$BUILD_LEADER = YES"
65-
- provider: pypi
66-
server: https://testpypi.python.org/pypi
67-
user: sorins
68-
password:
69-
secure: "E0cjANF7SLBdYrsnWLK8X/xWznqkF0JrP/DVfDazPzUYH6ynFeneyofzNJQPLTLsqe1eKXhuUJ/Sbl+RHFB0ySo/j/7NfYd/9pm8hpUkGCvR09IwtvMLgWKp3k10NWab03o2GOkSJSrLvZofyZBGR40wwu2O9uXPCb2rvucCGbw="
70-
distributions: "sdist bdist_wheel"
71-
on:
72-
branch: develop
73-
tags: false
74-
condition: "$BUILD_LEADER = YES"
55+
- provider: releases
56+
api_key:
57+
secure: gr9iOcQjdoAyUAim6FWKzJI9MBaJo9XKfGQGu7wdPXUFhg80Rp6GLJsowP+aU94NjXM1UQlVHDAy627WtjBlLH2SvmVEIIr7+UKBopBYuXG5jJ1m3wOZE+4f1Pqe9bqFc1DxgucqE8qF0sC24fIbNM2ToeyYrxrS6RoL2gRrX2I=
58+
file:
59+
- dist/$PACKAGE_NAME-$PACKAGE_VERSION*
60+
skip_cleanup: true
61+
on:
62+
tags: false
63+
branch: master
64+
condition: "$BUILD_LEADER = YES"
65+
- provider: pypi
66+
user: sorin
67+
password:
68+
secure: E0cjANF7SLBdYrsnWLK8X/xWznqkF0JrP/DVfDazPzUYH6ynFeneyofzNJQPLTLsqe1eKXhuUJ/Sbl+RHFB0ySo/j/7NfYd/9pm8hpUkGCvR09IwtvMLgWKp3k10NWab03o2GOkSJSrLvZofyZBGR40wwu2O9uXPCb2rvucCGbw=
69+
distributions: sdist bdist_wheel
70+
skip_cleanup: true
71+
on:
72+
tags: false
73+
condition: "$BUILD_LEADER = YES"
74+
branch: master
75+
- provider: pypi
76+
server: https://testpypi.python.org/pypi
77+
user: sorins
78+
password:
79+
secure: E0cjANF7SLBdYrsnWLK8X/xWznqkF0JrP/DVfDazPzUYH6ynFeneyofzNJQPLTLsqe1eKXhuUJ/Sbl+RHFB0ySo/j/7NfYd/9pm8hpUkGCvR09IwtvMLgWKp3k10NWab03o2GOkSJSrLvZofyZBGR40wwu2O9uXPCb2rvucCGbw=
80+
distributions: sdist bdist_wheel
81+
skip_cleanup: true
82+
on:
83+
tags: false
84+
condition: "$BUILD_LEADER = YES"
85+
branch: develop
86+
after_deploy:
87+
- echo "Now we only have tag the changeset and push..."
88+
- git tag $PACKAGE_VERSION -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER on $TRAVIS_BRANCH branch."
89+
- git push -q https://[email protected]/pycontribs/$PACKAGE_NAME $PACKAGE_VERSION
90+
addons:
91+
artifacts:
92+
debug: true
93+
paths:
94+
- dist/*
95+
target_paths: $PACKAGE_NAME/$TRAVIS_BRANCH/$TRAVIS_BUILD_NUMBER-$TRAVIS_PYTHON_VERSION
96+
working_dir: $TRAVIS_BUILD_DIR
97+
env:
98+
global:
99+
- secure: fuXwQL+KHQ96XkAFl2uQc8eK8dAjrgkup46tck/UGjVpdv1PT/yHmBKrvpFjDa50ueGbtBwTdKAwhyAmYuiZCk2IYHzdvBylCZBBji2FSpaTM59CVwgkVT6tx3HHO83X0mEX6ih9TJvZD5XhX+YUjopnseRXRq3ey3JZJXWN4RM=
100+
- secure: "pGQGM5YmHvOgaKihOyzb3k6bdqLQnZQ2OXO9QrfXlXwtop3zvZQi80Q+01l230x2psDWlwvqWTknAjAt1w463fYXPwpoSvKVCsLSSbjrf2l56nrDqnoir+n0CBy288+eIdaGEfzcxDiuULeKjlg08zrqjcjLjW0bDbBrlTXsb5U="

pytest.ini

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[pytest]
2+
norecursedirs = . .git .svn tox _build tmp* lib/third lib *.egg bin distutils build docs demo
3+
python_files = *.py
4+
addopts = -p no:xdist --ignore=setup.py --tb=long -rsxX -v --maxfail=10 tests
5+
# remove "--flake8" due to weir errors
6+
timeout=60
7+
# --maxfail=2 -n4
8+
# -n4 runs up to 4 parallel procs
9+
# --maxfail=2 fail fast, dude
10+
# --durations=3 report the top 3 longest tests
11+
12+
# these are important for distributed testing, to speedup their execution we minimize what we sync
13+
rsyncdirs = . demo docs
14+
rsyncignore = .hg .git
15+
flake8-max-line-length = 99
16+
#flake8-ignore=D,D102
17+
flake8-ignore=D D102 H405

requirements-dev.txt

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
coverage
2-
coveralls
3-
flake8
4-
flake8-pep257>=1.0.5
1+
# The order of packages is significant, because pip processes them in the order
2+
# of appearance. Changing the order has an impact on the overall integration
3+
# process, which may cause wedges in the gate later.
4+
5+
py >= 1.4
6+
7+
hacking
8+
59
pytest
610
pytest-cov
7-
pytest-timeout

setup.cfg

+3-20
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,9 @@ all_files = 1
1212
[upload_sphinx]
1313
upload-dir = docs/build/html
1414

15-
[pytest]
16-
norecursedirs = . .git .svn tox _build tmp* lib/third lib *.egg bin distutils build docs demo
17-
python_files = *.py
18-
addopts = -p no:xdist --ignore=setup.py --tb=long -rsxX -v --maxfail=10 tests
19-
# remove "--flake8" due to weir errors
20-
timeout=60
21-
# --maxfail=2 -n4
22-
# -n4 runs up to 4 parallel procs
23-
# --maxfail=2 fail fast, dude
24-
# --durations=3 report the top 3 longest tests
25-
26-
# these are important for distributed testing, to speedup their execution we minimize what we sync
27-
rsyncdirs = . demo docs
28-
rsyncignore = .hg .git
29-
flake8-max-line-length = 99
30-
#flake8-ignore=D,D102
31-
flake8-ignore=D D102
32-
3315
[flake8]
16+
enable-extensions = H106,H203,H904
17+
exclude=build,.eggs,.tox
18+
ignore=D,E402,H405,H
3419
max-line-length=160
35-
exclude=build
3620
statistics=yes
37-
ignore=D,E402

tests/test_wsdl.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
# See LBNLCopyright for copyright notice!
66
###########################################################################
77
"""Unittests."""
8+
import inspect
9+
import os
810
import sys
911
import unittest
10-
import os
11-
import inspect
1212
cmd_folder = os.path.abspath(os.path.join(os.path.split(inspect.getfile(
1313
inspect.currentframe()))[0], ".."))
1414
if cmd_folder not in sys.path:
1515
sys.path.insert(0, cmd_folder)
16+
from wstools.TimeoutSocket import TimeoutError # noqa E402
1617
from wstools.Utility import DOM # noqa E402
1718
from wstools.WSDLTools import WSDLReader # noqa E402
18-
from wstools.TimeoutSocket import TimeoutError # noqa E402
1919
try:
2020
import configparser
21-
except:
21+
except ImportError:
2222
from six.moves import configparser
2323

2424
cwd = 'tests'
@@ -88,38 +88,38 @@ def test_all(self):
8888
print("connection timed out")
8989
sys.stdout.flush()
9090
return
91-
except:
91+
except Exception:
9292
self.path = self.path + ": load failed, unable to start"
9393
raise
9494

9595
try:
9696
self.checkWSDLCollection('service', self.wsdl.services)
97-
except:
97+
except Exception:
9898
self.path = self.path + ": wsdl.services"
9999
raise
100100

101101
try:
102102
self.checkWSDLCollection('message', self.wsdl.messages)
103-
except:
103+
except Exception:
104104
self.path = self.path + ": wsdl.messages"
105105
raise
106106

107107
try:
108108
self.checkWSDLCollection('portType', self.wsdl.portTypes)
109-
except:
109+
except Exception:
110110
self.path = self.path + ": wsdl.portTypes"
111111
raise
112112

113113
try:
114114
self.checkWSDLCollection('binding', self.wsdl.bindings)
115-
except:
115+
except Exception:
116116
self.path = self.path + ": wsdl.bindings"
117117
raise
118118

119119
try:
120120
self.checkWSDLCollection('import', self.wsdl.imports,
121121
key='namespace')
122-
except:
122+
except Exception:
123123
self.path = self.path + ": wsdl.imports"
124124
raise
125125

@@ -139,7 +139,7 @@ def test_all(self):
139139
self.schemaAttributeGroupDeclarations(schema, snode)
140140
self.schemaElementDeclarations(schema, snode)
141141
self.schemaTypeDefinitions(schema, snode)
142-
except:
142+
except Exception:
143143
self.path = self.path + ": wsdl.types"
144144
raise
145145

tests/test_wstools_net.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# Joshua R. Boverhof, David W. Robertson, LBNL
55
# See LBNLCopyright for copyright notice!
66
###########################################################################
7-
import unittest
87
import test_wsdl
8+
import unittest
99

1010

1111
def makeTestSuite():

wstools/TimeoutSocket.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def connect(self, *addr):
4949
try:
5050
# Non-blocking mode
5151
sock.setblocking(0)
52-
apply(sock.connect, addr)
52+
sock.connect(*addr)
5353
sock.setblocking(timeout != 0)
5454
return 1
5555
except socket.error as why:
@@ -66,7 +66,7 @@ def connect(self, *addr):
6666
r, w, e = select.select([], [sock], [], timeout)
6767
if w:
6868
try:
69-
apply(sock.connect, addr)
69+
sock.connect(*addr)
7070
return 1
7171
except socket.error as why:
7272
if len(why.args) == 1:

wstools/UserTuple.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self, inittuple=None):
5454
self.data = ()
5555
if inittuple is not None:
5656
# XXX should this accept an arbitrary sequence?
57-
if type(inittuple) == type(self.data):
57+
if isinstance(inittuple, tuple):
5858
self.data = inittuple
5959
elif isinstance(inittuple, UserTuple):
6060
# this results in
@@ -94,7 +94,7 @@ def __cast(self, other):
9494
return other
9595

9696
def __cmp__(self, other):
97-
return cmp(self.data, self.__cast(other))
97+
return (self.data > self.__cast(other)) - (self.data < self.__cast(other))
9898

9999
def __contains__(self, item):
100100
return item in self.data

0 commit comments

Comments
 (0)