Skip to content

Commit 28123bb

Browse files
authored
Use pycodestyle for lint checks. (#2642)
* Use pycodestyle for lint checks. flake8 includes a few more useful checks, but it's annoying to only see it's output in Travis-CI results. This keeps Travis-CI and pep8speaks in sync. * Config fixup * Show issues from all patches with pep8speaks * lint in test_indexing.py * Lint adjust * blanket noqa * blanket ignore ambiguous variable name * Fix remaining lint errors
1 parent a70b3c4 commit 28123bb

File tree

8 files changed

+25
-36
lines changed

8 files changed

+25
-36
lines changed

.pep8speaks.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# File : .pep8speaks.yml
22

3+
# This should be kept in sync with the duplicate config in the [pycodestyle]
4+
# block of setup.cfg.
5+
36
scanner:
4-
diff_only: True # If True, errors caused by only the patch are shown
7+
diff_only: False # If True, errors caused by only the patch are shown
58

69
pycodestyle:
710
max-line-length: 79
811
ignore: # Errors and warnings to ignore
9-
- E402, # module level import not at top of file
10-
- E731, # do not assign a lambda expression, use a def
11-
- W503 # line break before binary operator
12-
- W504 # line break after binary operator
12+
- E402 # module level import not at top of file
13+
- E731 # do not assign a lambda expression, use a def
14+
- E741 # ambiguous variable name
15+
- W503 # line break before binary operator
16+
- W504 # line break after binary operator

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ matrix:
3131
- env: CONDA_ENV=py36-rasterio
3232
- env: CONDA_ENV=py36-zarr-dev
3333
- env: CONDA_ENV=docs
34-
- env: CONDA_ENV=flake8
34+
- env: CONDA_ENV=lint
3535
- env: CONDA_ENV=py36-hypothesis
3636

3737
allow_failures:
@@ -62,7 +62,7 @@ before_install:
6262
install:
6363
- if [[ "$CONDA_ENV" == "docs" ]]; then
6464
conda env create -n test_env --file doc/environment.yml;
65-
elif [[ "$CONDA_ENV" == "flake8" ]]; then
65+
elif [[ "$CONDA_ENV" == "lint" ]]; then
6666
conda env create -n test_env --file ci/requirements-py37.yml;
6767
else
6868
conda env create -n test_env --file ci/requirements-$CONDA_ENV.yml;
@@ -79,8 +79,8 @@ script:
7979
- if [[ "$CONDA_ENV" == "docs" ]]; then
8080
conda install -c conda-forge sphinx sphinx_rtd_theme sphinx-gallery numpydoc;
8181
sphinx-build -n -j auto -b html -d _build/doctrees doc _build/html;
82-
elif [[ "$CONDA_ENV" == "flake8" ]]; then
83-
flake8 xarray ;
82+
elif [[ "$CONDA_ENV" == "lint" ]]; then
83+
pycodestyle xarray ;
8484
elif [[ "$CONDA_ENV" == "py36-hypothesis" ]]; then
8585
pytest properties ;
8686
else

ci/requirements-py37.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
- pytest-cov
1515
- pytest-env
1616
- coveralls
17-
- flake8
17+
- pycodestyle
1818
- numpy
1919
- pandas
2020
- scipy
@@ -28,4 +28,4 @@ dependencies:
2828
- eccodes
2929
- pydap
3030
- pip:
31-
- cfgrib>=0.9.2
31+
- cfgrib>=0.9.2

setup.cfg

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@ filterwarnings =
1010
env =
1111
UVCDAT_ANONYMOUS_LOG=no
1212

13-
[flake8]
13+
# This should be kept in sync with .pep8speaks.yml
14+
[pycodestyle]
1415
max-line-length=79
15-
ignore=
16-
E402 # module level import not at top of file
17-
E731 # do not assign a lambda expression, use a def
18-
W503 # line break before binary operator
19-
W504 # line break after binary operator
20-
exclude=
21-
doc/
16+
ignore=E402,E731,E741,W503,W504
2217

2318
[isort]
2419
default_section=THIRDPARTY

xarray/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ def close(self):
806806
self._file_obj = None
807807

808808
def isin(self, test_elements):
809-
"""Tests each value in the array for whether it is in the supplied list.
809+
"""Tests each value in the array for whether it is in test elements.
810810
811811
Parameters
812812
----------

xarray/core/dataset.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ def coords(self):
10771077

10781078
@property
10791079
def data_vars(self):
1080-
"""Dictionary of xarray.DataArray objects corresponding to data variables
1080+
"""Dictionary of DataArray objects corresponding to data variables
10811081
"""
10821082
return DataVariables(self)
10831083

@@ -2171,8 +2171,8 @@ def swap_dims(self, dims_dict, inplace=None):
21712171
inplace=inplace)
21722172

21732173
def expand_dims(self, dim, axis=None):
2174-
"""Return a new object with an additional axis (or axes) inserted at the
2175-
corresponding position in the array shape.
2174+
"""Return a new object with an additional axis (or axes) inserted at
2175+
the corresponding position in the array shape.
21762176
21772177
If dim is already a scalar coordinate, it will be promoted to a 1D
21782178
coordinate consisting of a single value.
@@ -2256,8 +2256,8 @@ def expand_dims(self, dim, axis=None):
22562256

22572257
def set_index(self, indexes=None, append=False, inplace=None,
22582258
**indexes_kwargs):
2259-
"""Set Dataset (multi-)indexes using one or more existing coordinates or
2260-
variables.
2259+
"""Set Dataset (multi-)indexes using one or more existing coordinates
2260+
or variables.
22612261
22622262
Parameters
22632263
----------

xarray/core/pycompat.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,12 @@ def __exit__(self, exctype, excinst, exctb):
128128
# Inspired by discussions on http://bugs.python.org/issue13585
129129
class ExitStack(object):
130130
"""Context manager for dynamic management of a stack of exit callbacks
131-
132-
For example:
133-
134-
with ExitStack() as stack:
135-
files = [stack.enter_context(open(fname)) for fname in filenames]
136-
# All opened files will automatically be closed at the end of
137-
# the with statement, even if attempts to open files later
138-
# in the list raise an exception
139-
140131
"""
141132

142133
def __init__(self):
143134
self._exit_callbacks = deque()
144135

145136
def pop_all(self):
146-
"""Preserve the context stack by transferring it to a new instance"""
147137
new_stack = type(self)()
148138
new_stack._exit_callbacks = self._exit_callbacks
149139
self._exit_callbacks = deque()

xarray/tests/test_backends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2463,7 +2463,7 @@ def test_cmp_local_file(self):
24632463
assert actual.attrs.keys() == expected.attrs.keys()
24642464

24652465
with self.create_datasets() as (actual, expected):
2466-
assert_equal(actual.isel(l=2), expected.isel(l=2)) # noqa
2466+
assert_equal(actual[{'l': 2}], expected[{'l': 2}])
24672467

24682468
with self.create_datasets() as (actual, expected):
24692469
assert_equal(actual.isel(i=0, j=-1),

0 commit comments

Comments
 (0)