Skip to content

Commit d171d46

Browse files
committed
update flake8 >= 3.0 and code format accordingly
1 parent 1e419af commit d171d46

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ target/
6666

6767
# temp files
6868
*.sw*
69+
70+
# hdf5 file
71+
*.h5

pypaw/bins/count_overall_windows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
each category have and the number will then be used in the weighting
88
stage.
99
If "weight_output_file" is in the path file, then a default weight param
10-
file will also be genrated. Be sure to modify some values and then it can
10+
file will also be generated. Be sure to modify some values and then it can
1111
be used in the weighting stage.
1212
"""
1313
from __future__ import print_function, division, absolute_import

pypaw/convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def add_stationxml_to_asdf(ds, staxml_filelist, event=None,
7373
for tag, value in sta_dict.iteritems():
7474
count += 1
7575
inv = create_simple_inventory(
76-
value[0], value[1], latitude=value[2], longitude=value[3],
77-
elevation=value[4], depth=value[5], start_date=start_date)
76+
value[0], value[1], latitude=value[2], longitude=value[3],
77+
elevation=value[4], depth=value[5], start_date=start_date)
7878
ds.add_stationxml(inv)
7979
if status_bar > 0:
8080
drawProgressBar((count)/nstaxml,

pypaw/window_weights.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def extract_source_location(input_info):
153153
event_base = asdf_events[asdf_events.keys()[0]]
154154
origin = event_base.preferred_origin()
155155
src_info = {
156-
"latitude": origin.latitude, "longitude": origin.longitude,
157-
"depth_in_m": origin.depth}
156+
"latitude": origin.latitude, "longitude": origin.longitude,
157+
"depth_in_m": origin.depth}
158158

159159
return src_info
160160

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def run_tests(self):
6868
"seismology", "tomography", "adjoint", "signal", "inversion", "window"
6969
],
7070
install_requires=[
71-
"numpy", "obspy>=1.0.0", "flake8", "pytest", "nose", "future>=0.14.1",
72-
"pytomo3d", "pyasdf"
71+
"numpy", "obspy>=1.0.0", "flake8>=3.0", "pytest", "nose",
72+
"future>=0.14.1", "pytomo3d", "pyasdf"
7373
],
7474
entry_points={
7575
'console_scripts': consoles

tests/test_code_formatting.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
GNU General Public License, Version 3
1111
(http://www.gnu.org/copyleft/gpl.html)
1212
"""
13-
import flake8
14-
import flake8.engine
15-
import flake8.main
13+
from flake8.api import legacy as flake8
1614
import inspect
1715
import os
1816

@@ -46,16 +44,11 @@ def test_flake8():
4644
full_path = os.path.join(dirpath, py_file)
4745
files.append(full_path)
4846

49-
# Get the style checker with the default style.
50-
flake8_style = flake8.engine.get_style_guide(
51-
parse_argv=False, config_file=flake8.main.DEFAULT_CONFIG)
47+
style_guide = flake8.get_style_guide(ignore=['E24', 'W503', 'E226'])
48+
report = style_guide.check_files(files)
49+
assert report.get_statistics('E') == [], 'Flake8 found violations'
50+
assert report.total_errors == 0
5251

53-
report = flake8_style.check_files(files)
54-
55-
# Make sure at least 10 files are tested.
56-
assert report.counters["files"] > 10
57-
# And no errors occured.
58-
assert report.get_count() == 0
5952

6053
if __name__ == "__main__":
6154
test_flake8()

0 commit comments

Comments
 (0)