Skip to content

Commit 4254b4a

Browse files
authored
Lint (#3373)
* raise exception instance, not class * isort * isort * Bump mypy version
1 parent 283b4fe commit 4254b4a

18 files changed

+30
-29
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
hooks:
1212
- id: flake8
1313
- repo: https://github.com/pre-commit/mirrors-mypy
14-
rev: v0.720 # Must match ci/requirements/*.yml
14+
rev: v0.730 # Must match ci/requirements/*.yml
1515
hooks:
1616
- id: mypy
1717
# run these occasionally, ref discussion https://github.com/pydata/xarray/pull/3194

asv_bench/benchmarks/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def requires_dask():
1818
try:
1919
import dask # noqa: F401
2020
except ImportError:
21-
raise NotImplementedError
21+
raise NotImplementedError()
2222

2323

2424
def randn(shape, frac_nan=None, chunks=None, seed=0):

asv_bench/benchmarks/dataset_io.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def setup(self):
458458
try:
459459
import distributed
460460
except ImportError:
461-
raise NotImplementedError
461+
raise NotImplementedError()
462462
self.client = distributed.Client()
463463
self.write = create_delayed_write()
464464

ci/requirements/py36-min-all-deps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- iris=2.2.0
2121
- lxml=4.4.1 # optional dep of pydap
2222
- matplotlib=3.1.1
23-
- mypy==0.720 # Must match .pre-commit-config.yaml
23+
- mypy==0.730 # Must match .pre-commit-config.yaml
2424
- nc-time-axis=1.2.0
2525
- netcdf4=1.5.1.2
2626
- numba=0.45.1

ci/requirements/py36.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- iris>=1.10
2121
- lxml # optional dep of pydap
2222
- matplotlib
23-
- mypy==0.720 # Must match .pre-commit-config.yaml
23+
- mypy==0.730 # Must match .pre-commit-config.yaml
2424
- nc-time-axis
2525
- netcdf4
2626
- numba

ci/requirements/py37-windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- iris>=1.10
2121
- lxml # optional dep of pydap
2222
- matplotlib
23-
- mypy==0.720 # Must match .pre-commit-config.yaml
23+
- mypy==0.730 # Must match .pre-commit-config.yaml
2424
- nc-time-axis
2525
- netcdf4
2626
- numba

ci/requirements/py37.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
- iris>=1.10
2121
- lxml # optional dep of pydap
2222
- matplotlib
23-
- mypy==0.720 # Must match .pre-commit-config.yaml
23+
- mypy==0.730 # Must match .pre-commit-config.yaml
2424
- nc-time-axis
2525
- netcdf4
2626
- numba

properties/test_encode_decode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
These ones pass, just as you'd hope!
55
66
"""
7-
import pytest
7+
import pytest # isort:skip
88

99
pytest.importorskip("hypothesis")
1010

xarray/backends/common.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ def __len__(self):
8888
return len(self.variables)
8989

9090
def get_dimensions(self): # pragma: no cover
91-
raise NotImplementedError
91+
raise NotImplementedError()
9292

9393
def get_attrs(self): # pragma: no cover
94-
raise NotImplementedError
94+
raise NotImplementedError()
9595

9696
def get_variables(self): # pragma: no cover
97-
raise NotImplementedError
97+
raise NotImplementedError()
9898

9999
def get_encoding(self):
100100
return {}
@@ -247,13 +247,13 @@ def encode_attribute(self, a):
247247
return a
248248

249249
def set_dimension(self, d, l): # pragma: no cover
250-
raise NotImplementedError
250+
raise NotImplementedError()
251251

252252
def set_attribute(self, k, v): # pragma: no cover
253-
raise NotImplementedError
253+
raise NotImplementedError()
254254

255255
def set_variable(self, k, v): # pragma: no cover
256-
raise NotImplementedError
256+
raise NotImplementedError()
257257

258258
def store_dataset(self, dataset):
259259
"""

xarray/backends/file_manager.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FileManager:
2828

2929
def acquire(self, needs_lock=True):
3030
"""Acquire the file object from this manager."""
31-
raise NotImplementedError
31+
raise NotImplementedError()
3232

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

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

4646

4747
class CachingFileManager(FileManager):

xarray/coding/cftime_offsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _get_day_of_month(other, day_option):
181181
elif day_option is None:
182182
# Note: unlike `_shift_month`, _get_day_of_month does not
183183
# allow day_option = None
184-
raise NotImplementedError
184+
raise NotImplementedError()
185185
else:
186186
raise ValueError(day_option)
187187

xarray/coding/variables.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ class VariableCoder:
3636
def encode(self, variable, name=None): # pragma: no cover
3737
# type: (Variable, Any) -> Variable
3838
"""Convert an encoded variable to a decoded variable."""
39-
raise NotImplementedError
39+
raise NotImplementedError()
4040

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

4646

4747
class _ElementwiseFunctionArray(indexing.ExplicitlyIndexedNDArrayMixin):

xarray/core/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ def __exit__(self, exc_type, exc_value, traceback) -> None:
12161216

12171217
def __getitem__(self, value):
12181218
# implementations of this class should implement this method
1219-
raise NotImplementedError
1219+
raise NotImplementedError()
12201220

12211221

12221222
def full_like(other, fill_value, dtype: DTypeLike = None):

xarray/core/concat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from . import dtypes, utils
66
from .alignment import align
7-
from .merge import unique_variable, _VALID_COMPAT
7+
from .merge import _VALID_COMPAT, unique_variable
88
from .variable import IndexVariable, Variable, as_variable
99
from .variable import concat as concat_vars
1010

xarray/core/coordinates.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
Hashable,
77
Iterator,
88
Mapping,
9-
Set,
109
Sequence,
10+
Set,
1111
Tuple,
1212
Union,
1313
cast,
@@ -17,7 +17,7 @@
1717

1818
from . import formatting, indexing
1919
from .indexes import Indexes
20-
from .merge import merge_coords, merge_coordinates_without_align
20+
from .merge import merge_coordinates_without_align, merge_coords
2121
from .utils import Frozen, ReprObject, either_dict_or_kwargs
2222
from .variable import Variable
2323

@@ -53,10 +53,10 @@ def indexes(self) -> Indexes:
5353

5454
@property
5555
def variables(self):
56-
raise NotImplementedError
56+
raise NotImplementedError()
5757

5858
def _update_coords(self, coords, indexes):
59-
raise NotImplementedError
59+
raise NotImplementedError()
6060

6161
def __iter__(self) -> Iterator["Hashable"]:
6262
# needs to be in the same order as the dataset variables

xarray/core/dataset.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
from .merge import (
6565
dataset_merge_method,
6666
dataset_update_method,
67-
merge_data_and_coords,
6867
merge_coordinates_without_align,
68+
merge_data_and_coords,
6969
)
7070
from .options import OPTIONS, _get_keep_attrs
7171
from .pycompat import dask_array_type
@@ -76,9 +76,9 @@
7676
decode_numpy_dict_values,
7777
either_dict_or_kwargs,
7878
hashable,
79-
maybe_wrap_array,
8079
is_dict_like,
8180
is_list_like,
81+
maybe_wrap_array,
8282
)
8383
from .variable import IndexVariable, Variable, as_variable, broadcast_variables
8484

xarray/tests/test_backends.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class DatasetIOBase:
237237
file_format = None # type: Optional[str]
238238

239239
def create_store(self):
240-
raise NotImplementedError
240+
raise NotImplementedError()
241241

242242
@contextlib.contextmanager
243243
def roundtrip(

xarray/tests/test_concat.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from xarray import DataArray, Dataset, Variable, concat
88
from xarray.core import dtypes, merge
9+
910
from . import (
1011
InaccessibleArray,
1112
assert_array_equal,

0 commit comments

Comments
 (0)