Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/fsspec-2023.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamman authored Dec 20, 2023
2 parents f9222e5 + b5f79dd commit aa48a01
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -69,4 +69,4 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
submodules: true
fetch-depth: 0

- uses: actions/setup-python@v4.7.1
- uses: actions/setup-python@v5.0.0
name: Install Python
with:
python-version: '3.8'
Expand Down
14 changes: 6 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,25 @@ default_stages: [commit, push]
default_language_version:
python: python3
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.224'
rev: 'v0.1.8'
hooks:
- id: ruff
# Respect `exclude` and `extend-exclude` settings.
args: ["--force-exclude"]
- repo: https://github.com/psf/black
rev: 23.10.1
rev: 23.12.0
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
rev: v2.2.6
hooks:
- id: codespell
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.7.1
hooks:
- id: mypy
files: zarr
Expand Down
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
2 changes: 1 addition & 1 deletion zarr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2536,7 +2536,7 @@ def hexdigest(self, hashname="sha1"):
checksum = binascii.hexlify(self.digest(hashname=hashname))

# This is a bytes object on Python 3 and we want a str.
if type(checksum) is not str:
if not isinstance(checksum, str):
checksum = checksum.decode("utf8")

return checksum
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 aa48a01

Please sign in to comment.