diff --git a/.pep8speaks.yml b/.pep8speaks.yml index aedce6e44eb..018003f2223 100644 --- a/.pep8speaks.yml +++ b/.pep8speaks.yml @@ -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 diff --git a/.travis.yml b/.travis.yml index fbb7221d7ea..337447dbf69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: @@ -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; @@ -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 diff --git a/ci/requirements-py37.yml b/ci/requirements-py37.yml index 86a44ed5398..afd18e37a75 100644 --- a/ci/requirements-py37.yml +++ b/ci/requirements-py37.yml @@ -14,7 +14,7 @@ dependencies: - pytest-cov - pytest-env - coveralls - - flake8 + - pycodestyle - numpy - pandas - scipy @@ -28,4 +28,4 @@ dependencies: - eccodes - pydap - pip: - - cfgrib>=0.9.2 \ No newline at end of file + - cfgrib>=0.9.2 diff --git a/setup.cfg b/setup.cfg index 847415ac04d..21ba5ee8dec 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/xarray/core/common.py b/xarray/core/common.py index 5b090bf0d2f..674c3b19b06 100644 --- a/xarray/core/common.py +++ b/xarray/core/common.py @@ -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 ---------- diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 62c6e98c954..9380023c5b7 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -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) @@ -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. @@ -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 ---------- diff --git a/xarray/core/pycompat.py b/xarray/core/pycompat.py index b980bc279b0..67921b5d145 100644 --- a/xarray/core/pycompat.py +++ b/xarray/core/pycompat.py @@ -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() diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 48c2f64c8db..02ac06903c9 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -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),