Skip to content

Commit

Permalink
Lint (#3373)
Browse files Browse the repository at this point in the history
* raise exception instance, not class

* isort

* isort

* Bump mypy version
  • Loading branch information
crusaderky authored Oct 4, 2019
1 parent 283b4fe commit 4254b4a
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.720 # Must match ci/requirements/*.yml
rev: v0.730 # Must match ci/requirements/*.yml
hooks:
- id: mypy
# run these occasionally, ref discussion https://github.com/pydata/xarray/pull/3194
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def requires_dask():
try:
import dask # noqa: F401
except ImportError:
raise NotImplementedError
raise NotImplementedError()


def randn(shape, frac_nan=None, chunks=None, seed=0):
Expand Down
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/dataset_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def setup(self):
try:
import distributed
except ImportError:
raise NotImplementedError
raise NotImplementedError()
self.client = distributed.Client()
self.write = create_delayed_write()

Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/py36-min-all-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies:
- iris=2.2.0
- lxml=4.4.1 # optional dep of pydap
- matplotlib=3.1.1
- mypy==0.720 # Must match .pre-commit-config.yaml
- mypy==0.730 # Must match .pre-commit-config.yaml
- nc-time-axis=1.2.0
- netcdf4=1.5.1.2
- numba=0.45.1
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/py36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies:
- iris>=1.10
- lxml # optional dep of pydap
- matplotlib
- mypy==0.720 # Must match .pre-commit-config.yaml
- mypy==0.730 # Must match .pre-commit-config.yaml
- nc-time-axis
- netcdf4
- numba
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/py37-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies:
- iris>=1.10
- lxml # optional dep of pydap
- matplotlib
- mypy==0.720 # Must match .pre-commit-config.yaml
- mypy==0.730 # Must match .pre-commit-config.yaml
- nc-time-axis
- netcdf4
- numba
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies:
- iris>=1.10
- lxml # optional dep of pydap
- matplotlib
- mypy==0.720 # Must match .pre-commit-config.yaml
- mypy==0.730 # Must match .pre-commit-config.yaml
- nc-time-axis
- netcdf4
- numba
Expand Down
2 changes: 1 addition & 1 deletion properties/test_encode_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
These ones pass, just as you'd hope!
"""
import pytest
import pytest # isort:skip

pytest.importorskip("hypothesis")

Expand Down
12 changes: 6 additions & 6 deletions xarray/backends/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ def __len__(self):
return len(self.variables)

def get_dimensions(self): # pragma: no cover
raise NotImplementedError
raise NotImplementedError()

def get_attrs(self): # pragma: no cover
raise NotImplementedError
raise NotImplementedError()

def get_variables(self): # pragma: no cover
raise NotImplementedError
raise NotImplementedError()

def get_encoding(self):
return {}
Expand Down Expand Up @@ -247,13 +247,13 @@ def encode_attribute(self, a):
return a

def set_dimension(self, d, l): # pragma: no cover
raise NotImplementedError
raise NotImplementedError()

def set_attribute(self, k, v): # pragma: no cover
raise NotImplementedError
raise NotImplementedError()

def set_variable(self, k, v): # pragma: no cover
raise NotImplementedError
raise NotImplementedError()

def store_dataset(self, dataset):
"""
Expand Down
6 changes: 3 additions & 3 deletions xarray/backends/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FileManager:

def acquire(self, needs_lock=True):
"""Acquire the file object from this manager."""
raise NotImplementedError
raise NotImplementedError()

def acquire_context(self, needs_lock=True):
"""Context manager for acquiring a file. Yields a file object.
Expand All @@ -37,11 +37,11 @@ def acquire_context(self, needs_lock=True):
(i.e., removes it from any cache) if an exception is raised from the
context. It *does not* automatically close the file.
"""
raise NotImplementedError
raise NotImplementedError()

def close(self, needs_lock=True):
"""Close the file object associated with this manager, if needed."""
raise NotImplementedError
raise NotImplementedError()


class CachingFileManager(FileManager):
Expand Down
2 changes: 1 addition & 1 deletion xarray/coding/cftime_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _get_day_of_month(other, day_option):
elif day_option is None:
# Note: unlike `_shift_month`, _get_day_of_month does not
# allow day_option = None
raise NotImplementedError
raise NotImplementedError()
else:
raise ValueError(day_option)

Expand Down
4 changes: 2 additions & 2 deletions xarray/coding/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class VariableCoder:
def encode(self, variable, name=None): # pragma: no cover
# type: (Variable, Any) -> Variable
"""Convert an encoded variable to a decoded variable."""
raise NotImplementedError
raise NotImplementedError()

def decode(self, variable, name=None): # pragma: no cover
# type: (Variable, Any) -> Variable
"""Convert an decoded variable to a encoded variable."""
raise NotImplementedError
raise NotImplementedError()


class _ElementwiseFunctionArray(indexing.ExplicitlyIndexedNDArrayMixin):
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ def __exit__(self, exc_type, exc_value, traceback) -> None:

def __getitem__(self, value):
# implementations of this class should implement this method
raise NotImplementedError
raise NotImplementedError()


def full_like(other, fill_value, dtype: DTypeLike = None):
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from . import dtypes, utils
from .alignment import align
from .merge import unique_variable, _VALID_COMPAT
from .merge import _VALID_COMPAT, unique_variable
from .variable import IndexVariable, Variable, as_variable
from .variable import concat as concat_vars

Expand Down
8 changes: 4 additions & 4 deletions xarray/core/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Hashable,
Iterator,
Mapping,
Set,
Sequence,
Set,
Tuple,
Union,
cast,
Expand All @@ -17,7 +17,7 @@

from . import formatting, indexing
from .indexes import Indexes
from .merge import merge_coords, merge_coordinates_without_align
from .merge import merge_coordinates_without_align, merge_coords
from .utils import Frozen, ReprObject, either_dict_or_kwargs
from .variable import Variable

Expand Down Expand Up @@ -53,10 +53,10 @@ def indexes(self) -> Indexes:

@property
def variables(self):
raise NotImplementedError
raise NotImplementedError()

def _update_coords(self, coords, indexes):
raise NotImplementedError
raise NotImplementedError()

def __iter__(self) -> Iterator["Hashable"]:
# needs to be in the same order as the dataset variables
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
from .merge import (
dataset_merge_method,
dataset_update_method,
merge_data_and_coords,
merge_coordinates_without_align,
merge_data_and_coords,
)
from .options import OPTIONS, _get_keep_attrs
from .pycompat import dask_array_type
Expand All @@ -76,9 +76,9 @@
decode_numpy_dict_values,
either_dict_or_kwargs,
hashable,
maybe_wrap_array,
is_dict_like,
is_list_like,
maybe_wrap_array,
)
from .variable import IndexVariable, Variable, as_variable, broadcast_variables

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 @@ -237,7 +237,7 @@ class DatasetIOBase:
file_format = None # type: Optional[str]

def create_store(self):
raise NotImplementedError
raise NotImplementedError()

@contextlib.contextmanager
def roundtrip(
Expand Down
1 change: 1 addition & 0 deletions xarray/tests/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from xarray import DataArray, Dataset, Variable, concat
from xarray.core import dtypes, merge

from . import (
InaccessibleArray,
assert_array_equal,
Expand Down

0 comments on commit 4254b4a

Please sign in to comment.