Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pycodestyle for lint checks. #2642

Merged
merged 8 commits into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .pep8speaks.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# File : .pep8speaks.yml

# This should be kept in sync with the duplicate config in the [pycodestyle]
# block of setup.cfg.

scanner:
diff_only: True # If True, errors caused by only the patch are shown
diff_only: False # If True, errors caused by only the patch are shown

pycodestyle:
max-line-length: 79
ignore: # Errors and warnings to ignore
- E402, # module level import not at top of file
- E731, # do not assign a lambda expression, use a def
- W503 # line break before binary operator
- W504 # line break after binary operator
- E402 # module level import not at top of file
- E731 # do not assign a lambda expression, use a def
- E741 # ambiguous variable name
- W503 # line break before binary operator
- W504 # line break after binary operator
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ matrix:
- env: CONDA_ENV=py36-rasterio
- env: CONDA_ENV=py36-zarr-dev
- env: CONDA_ENV=docs
- env: CONDA_ENV=flake8
- env: CONDA_ENV=lint
- env: CONDA_ENV=py36-hypothesis

allow_failures:
Expand Down Expand Up @@ -62,7 +62,7 @@ before_install:
install:
- if [[ "$CONDA_ENV" == "docs" ]]; then
conda env create -n test_env --file doc/environment.yml;
elif [[ "$CONDA_ENV" == "flake8" ]]; then
elif [[ "$CONDA_ENV" == "lint" ]]; then
conda env create -n test_env --file ci/requirements-py37.yml;
else
conda env create -n test_env --file ci/requirements-$CONDA_ENV.yml;
Expand All @@ -79,8 +79,8 @@ script:
- if [[ "$CONDA_ENV" == "docs" ]]; then
conda install -c conda-forge sphinx sphinx_rtd_theme sphinx-gallery numpydoc;
sphinx-build -n -j auto -b html -d _build/doctrees doc _build/html;
elif [[ "$CONDA_ENV" == "flake8" ]]; then
flake8 xarray ;
elif [[ "$CONDA_ENV" == "lint" ]]; then
pycodestyle xarray ;
elif [[ "$CONDA_ENV" == "py36-hypothesis" ]]; then
pytest properties ;
else
Expand Down
4 changes: 2 additions & 2 deletions ci/requirements-py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- pytest-cov
- pytest-env
- coveralls
- flake8
- pycodestyle
- numpy
- pandas
- scipy
Expand All @@ -28,4 +28,4 @@ dependencies:
- eccodes
- pydap
- pip:
- cfgrib>=0.9.2
- cfgrib>=0.9.2
11 changes: 3 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ filterwarnings =
env =
UVCDAT_ANONYMOUS_LOG=no

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

[isort]
default_section=THIRDPARTY
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ def close(self):
self._file_obj = None

def isin(self, test_elements):
"""Tests each value in the array for whether it is in the supplied list.
"""Tests each value in the array for whether it is in test elements.

Parameters
----------
Expand Down
10 changes: 5 additions & 5 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ def coords(self):

@property
def data_vars(self):
"""Dictionary of xarray.DataArray objects corresponding to data variables
"""Dictionary of DataArray objects corresponding to data variables
"""
return DataVariables(self)

Expand Down Expand Up @@ -2171,8 +2171,8 @@ def swap_dims(self, dims_dict, inplace=None):
inplace=inplace)

def expand_dims(self, dim, axis=None):
"""Return a new object with an additional axis (or axes) inserted at the
corresponding position in the array shape.
"""Return a new object with an additional axis (or axes) inserted at
the corresponding position in the array shape.

If dim is already a scalar coordinate, it will be promoted to a 1D
coordinate consisting of a single value.
Expand Down Expand Up @@ -2256,8 +2256,8 @@ def expand_dims(self, dim, axis=None):

def set_index(self, indexes=None, append=False, inplace=None,
**indexes_kwargs):
"""Set Dataset (multi-)indexes using one or more existing coordinates or
variables.
"""Set Dataset (multi-)indexes using one or more existing coordinates
or variables.

Parameters
----------
Expand Down
10 changes: 0 additions & 10 deletions xarray/core/pycompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,12 @@ def __exit__(self, exctype, excinst, exctb):
# Inspired by discussions on http://bugs.python.org/issue13585
class ExitStack(object):
"""Context manager for dynamic management of a stack of exit callbacks

For example:

with ExitStack() as stack:
files = [stack.enter_context(open(fname)) for fname in filenames]
# All opened files will automatically be closed at the end of
# the with statement, even if attempts to open files later
# in the list raise an exception

"""

def __init__(self):
self._exit_callbacks = deque()

def pop_all(self):
"""Preserve the context stack by transferring it to a new instance"""
new_stack = type(self)()
new_stack._exit_callbacks = self._exit_callbacks
self._exit_callbacks = deque()
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ def test_cmp_local_file(self):
assert actual.attrs.keys() == expected.attrs.keys()

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

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