Skip to content

Enable some ruff rules (RUF) and fix issues #1867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Docs

Maintenance
~~~~~~~~~~~
* Enable some ruff rules (RUF) and fix issues.
By :user:`Dimitri Papadopoulos Orfanos <DimitriPapadopoulos>` :issue:`1867`.

Deprecations
~~~~~~~~~~~~
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ exclude = [

[tool.ruff.lint]
extend-select = [
"B"
"B",
"RUF"
]
ignore = [
"RUF003",
"RUF005",
"RUF012",
]

[tool.black]
Expand Down
2 changes: 1 addition & 1 deletion zarr/_storage/absstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ABSStore(Store):
-----
In order to use this store, you must install the Microsoft Azure Storage SDK for Python,
``azure-storage-blob>=12.5.0``.
""" # noqa: E501
"""

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion zarr/_storage/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def get_partial_values(
from the end of the file.
A key may occur multiple times with different ranges.
Inserts None for missing keys into the returned list."""
results: List[Union[bytes, memoryview, bytearray]] = [None] * len(key_ranges) # type: ignore[list-item] # noqa: E501
results: List[Union[bytes, memoryview, bytearray]] = [None] * len(key_ranges) # type: ignore[list-item]
indexed_ranges_by_key: Dict[str, List[Tuple[int, Tuple[int, Optional[int]]]]] = defaultdict(
list
)
Expand Down
2 changes: 1 addition & 1 deletion zarr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2405,7 +2405,7 @@ def __repr__(self):
r = f"<{t.__module__}.{t.__name__}"
if self.name:
r += f" {self.name!r}"
r += f" {str(self.shape)}"
r += f" {self.shape!s}"
r += f" {self.dtype}"
if self._read_only:
r += " read-only"
Expand Down
12 changes: 6 additions & 6 deletions zarr/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,37 @@
def get_extended_dtype_info(dtype) -> dict:
if dtype.str in _v3_complex_types:
return dict(
extension="https://zarr-specs.readthedocs.io/en/core-protocol-v3.0-dev/protocol/extensions/complex-dtypes/v1.0.html", # noqa
extension="https://zarr-specs.readthedocs.io/en/core-protocol-v3.0-dev/protocol/extensions/complex-dtypes/v1.0.html",
type=dtype.str,
fallback=None,
)
elif dtype.str == "|O":
return dict(
extension="TODO: object array protocol URL", # noqa
extension="TODO: object array protocol URL",
type=dtype.str,
fallback=None,
)
elif dtype.str.startswith("|S"):
return dict(
extension="TODO: bytestring array protocol URL", # noqa
extension="TODO: bytestring array protocol URL",
type=dtype.str,
fallback=None,
)
elif dtype.str.startswith("<U") or dtype.str.startswith(">U"):
return dict(
extension="TODO: unicode array protocol URL", # noqa
extension="TODO: unicode array protocol URL",
type=dtype.str,
fallback=None,
)
elif dtype.str.startswith("|V"):
return dict(
extension="TODO: structured array protocol URL", # noqa
extension="TODO: structured array protocol URL",
type=dtype.descr,
fallback=None,
)
elif dtype.str in _v3_datetime_types:
return dict(
extension="https://zarr-specs.readthedocs.io/en/latest/extensions/data-types/datetime/v1.0.html", # noqa
extension="https://zarr-specs.readthedocs.io/en/latest/extensions/data-types/datetime/v1.0.html",
type=dtype.str,
fallback=None,
)
Expand Down
2 changes: 1 addition & 1 deletion zarr/n5.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def compressor_config_to_zarr(compressor_config: Dict[str, Any]) -> Optional[Dic
zarr_config["filters"] = None

elif codec_id == "gzip":
if "useZlib" in compressor_config and compressor_config["useZlib"]:
if compressor_config.get("useZlib"):
zarr_config["id"] = "zlib"
zarr_config["level"] = compressor_config["level"]
else:
Expand Down
2 changes: 1 addition & 1 deletion zarr/tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from zarr.sync import ProcessSynchronizer, ThreadSynchronizer

# zarr_version fixture must be imported although not used directly here
from zarr.tests.test_attrs import TestAttributes, zarr_version # noqa
from zarr.tests.test_attrs import TestAttributes, zarr_version
from zarr.tests.test_core import TestArray
from zarr.tests.test_hierarchy import TestGroup

Expand Down
Loading