Skip to content
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

Apply ruff-specific rules (RUF) #434

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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: 1 addition & 1 deletion ome_zarr/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def parse_csv_value(value: str, col_type: str) -> Union[str, float, int, bool]:
if col_type == "d":
rv = float(value)
elif col_type == "l":
rv = int(round(float(value)))
rv = round(float(value))
elif col_type == "b":
rv = bool(value)
except ValueError:
Expand Down
2 changes: 1 addition & 1 deletion ome_zarr/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def basename(self) -> str:
>>> ZarrLocation("https://example.com/baz/").basename()
'baz'
"""
path = self.__path.endswith("/") and self.__path[0:-1] or self.__path
path = (self.__path.endswith("/") and self.__path[0:-1]) or self.__path
return path.split("/")[-1]

# TODO: update to from __future__ import annotations with 3.7+
Expand Down
2 changes: 1 addition & 1 deletion ome_zarr/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _get_valid_axes(
ndim: Optional[int] = None,
axes: Optional[Union[str, list[str], list[dict[str, str]]]] = None,
fmt: Format = CurrentFormat(),
) -> Union[None, list[str], list[dict[str, str]]]:
) -> Union[list[str], list[dict[str, str]], None]:
"""Returns list of axes valid for fmt.version or raise exception if invalid"""

if fmt.version in ("0.1", "0.2"):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_label(self):

def test_omero(self):
reader = Reader(parse_url(str(self.path)))()
image_node = list(reader)[0]
image_node = next(iter(reader))
omero = image_node.zarr.root_attrs.get("omero")
assert "channels" in omero
assert isinstance(omero["channels"], list)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def assert_data(self, path, shape, fmt, mode="r"):
loc = parse_url(path, mode=mode, fmt=fmt)
assert loc
reader = Reader(loc)
node = list(reader())[0]
node = next(iter(reader()))
assert Multiscales.matches(node.zarr)
assert node.data[0].shape == shape
assert np.max(node.data[0]) > 0
Expand Down
8 changes: 4 additions & 4 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_writer(

# Verify
reader = Reader(parse_url(f"{self.path}/test"))
node = list(reader())[0]
node = next(iter(reader()))
assert Multiscales.matches(node.zarr)
if version.version in ("0.1", "0.2"):
# v0.1 and v0.2 MUST be 5D
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_write_image_current(self, array_constructor):
data = array_constructor(data)
write_image(data, self.group, axes="zyx")
reader = Reader(parse_url(f"{self.path}/test"))
image_node = list(reader())[0]
image_node = next(iter(reader()))
for transfs in image_node.metadata["coordinateTransformations"]:
assert len(transfs) == 1
assert transfs[0]["type"] == "scale"
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_write_image_dask(self, read_from_zarr, compute):
dask_delayed_jobs = persist(*dask_delayed_jobs)

reader = Reader(parse_url(f"{self.path}/test"))
image_node = list(reader())[0]
image_node = next(iter(reader()))
first_chunk = [c[0] for c in image_node.data[0].chunks]
assert tuple(first_chunk) == _retuple(chunks, image_node.data[0].shape)
for level, transfs in enumerate(
Expand Down Expand Up @@ -1069,7 +1069,7 @@ def scaler(self, request):
def verify_label_data(self, label_name, label_data, fmt, shape, transformations):
# Verify image data
reader = Reader(parse_url(f"{self.path}/labels/{label_name}"))
node = list(reader())[0]
node = next(iter(reader()))
assert Multiscales.matches(node.zarr)
if fmt.version in ("0.1", "0.2"):
# v0.1 and v0.2 MUST be 5D
Expand Down
Loading