Skip to content

Commit

Permalink
Remove unused mypy ignore comments (#1602)
Browse files Browse the repository at this point in the history
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
  • Loading branch information
dstansby and d-v-b authored Dec 18, 2023
1 parent 4d79cfc commit 12abd4e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ exclude = '''
'''

[tool.mypy]
python_version = "3.8"
ignore_missing_imports = true
follow_imports = "silent"
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true

[tool.pytest.ini_options]
doctest_optionflags = [
Expand Down
4 changes: 2 additions & 2 deletions zarr/_storage/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,10 @@ def _rmdir_from_keys_v3(store: StoreV3, path: str = "") -> None:
sfx = _get_metadata_suffix(store)
array_meta_file = meta_dir + ".array" + sfx
if array_meta_file in store:
store.erase(array_meta_file) # type: ignore
store.erase(array_meta_file)
group_meta_file = meta_dir + ".group" + sfx
if group_meta_file in store:
store.erase(group_meta_file) # type: ignore
store.erase(group_meta_file)


def _listdir_from_keys(store: BaseStore, path: Optional[str] = None) -> List[str]:
Expand Down
2 changes: 1 addition & 1 deletion zarr/_storage/v3_storage_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def erase_prefix(self, prefix):

def rmdir(self, path=None):
path = normalize_storage_path(path)
_rmdir_from_keys_v3(self, path) # type: ignore
_rmdir_from_keys_v3(self, path)

def __contains__(self, key):
if self._is_data_key(key):
Expand Down
4 changes: 2 additions & 2 deletions zarr/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ def decode_fill_value(cls, v: Any, dtype: np.dtype, object_codec: Any = None) ->
return np.array(v, dtype=dtype)[()]
elif dtype.kind in "c":
v = (
cls.decode_fill_value(v[0], dtype.type().real.dtype), # type: ignore
cls.decode_fill_value(v[1], dtype.type().imag.dtype), # type: ignore
cls.decode_fill_value(v[0], dtype.type().real.dtype),
cls.decode_fill_value(v[1], dtype.type().imag.dtype),
)
v = v[0] + 1j * v[1]
return np.array(v, dtype=dtype)[()]
Expand Down
12 changes: 6 additions & 6 deletions zarr/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def rmdir(store: StoreLike, path: Path = None):
store_version = getattr(store, "_store_version", 2)
if hasattr(store, "rmdir") and store.is_erasable(): # type: ignore
# pass through
store.rmdir(path) # type: ignore
store.rmdir(path)
else:
# slow version, delete one key at a time
if store_version == 2:
Expand Down Expand Up @@ -236,7 +236,7 @@ def listdir(store: BaseStore, path: Path = None):
path = normalize_storage_path(path)
if hasattr(store, "listdir"):
# pass through
return store.listdir(path) # type: ignore
return store.listdir(path)
else:
# slow version, iterate through all keys
warnings.warn(
Expand Down Expand Up @@ -289,7 +289,7 @@ def getsize(store: BaseStore, path: Path = None) -> int:
if hasattr(store, "getsize"):
# pass through
path = normalize_storage_path(path)
return store.getsize(path) # type: ignore
return store.getsize(path)
elif isinstance(store, MutableMapping):
return _getsize(store, path)
else:
Expand Down Expand Up @@ -627,7 +627,7 @@ def _init_array_metadata(

key = _prefix_to_array_key(store, _path_to_prefix(path))
if hasattr(store, "_metadata_class"):
store[key] = store._metadata_class.encode_array_metadata(meta) # type: ignore
store[key] = store._metadata_class.encode_array_metadata(meta)
else:
store[key] = encode_array_metadata(meta)

Expand Down Expand Up @@ -730,10 +730,10 @@ def _init_group_metadata(
if store_version == 3:
meta = {"attributes": {}} # type: ignore
else:
meta = {} # type: ignore
meta = {}
key = _prefix_to_group_key(store, _path_to_prefix(path))
if hasattr(store, "_metadata_class"):
store[key] = store._metadata_class.encode_group_metadata(meta) # type: ignore
store[key] = store._metadata_class.encode_group_metadata(meta)
else:
store[key] = encode_group_metadata(meta)

Expand Down
2 changes: 1 addition & 1 deletion zarr/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def normalize_chunks(chunks: Any, shape: Tuple[int, ...], typesize: int) -> Tupl
def normalize_dtype(dtype: Union[str, np.dtype], object_codec) -> Tuple[np.dtype, Any]:
# convenience API for object arrays
if inspect.isclass(dtype):
dtype = dtype.__name__ # type: ignore
dtype = dtype.__name__
if isinstance(dtype, str):
# allow ':' to delimit class from codec arguments
tokens = dtype.split(":")
Expand Down

0 comments on commit 12abd4e

Please sign in to comment.