Skip to content

Commit e60dbaf

Browse files
Apply ruff/flake8-return rule RET504
RET504 Unnecessary assignment before `return` statement
1 parent 6694552 commit e60dbaf

File tree

6 files changed

+10
-19
lines changed

6 files changed

+10
-19
lines changed

src/zarr/codecs/transpose.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,14 @@ async def _decode_single(
9696
chunk_spec: ArraySpec,
9797
) -> NDBuffer:
9898
inverse_order = np.argsort(self.order)
99-
chunk_array = chunk_array.transpose(inverse_order)
100-
return chunk_array
99+
return chunk_array.transpose(inverse_order)
101100

102101
async def _encode_single(
103102
self,
104103
chunk_array: NDBuffer,
105104
_chunk_spec: ArraySpec,
106105
) -> NDBuffer | None:
107-
chunk_array = chunk_array.transpose(self.order)
108-
return chunk_array
106+
return chunk_array.transpose(self.order)
109107

110108
def compute_encoded_size(self, input_byte_length: int, _chunk_spec: ArraySpec) -> int:
111109
return input_byte_length

src/zarr/core/array.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ def from_dict(
331331
data: dict[str, JSON],
332332
) -> AsyncArray:
333333
metadata = parse_array_metadata(data)
334-
async_array = cls(metadata=metadata, store_path=store_path)
335-
return async_array
334+
return cls(metadata=metadata, store_path=store_path)
336335

337336
@classmethod
338337
async def open(

src/zarr/core/group.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,10 @@ def from_dict(
204204
store_path: StorePath,
205205
data: dict[str, Any],
206206
) -> AsyncGroup:
207-
group = cls(
207+
return cls(
208208
metadata=GroupMetadata.from_dict(data),
209209
store_path=store_path,
210210
)
211-
return group
212211

213212
async def getitem(
214213
self,
@@ -890,8 +889,7 @@ def members(self, max_depth: int | None = 0) -> tuple[tuple[str, Array | Group],
890889
"""
891890
_members = self._sync_iter(self._async_group.members(max_depth=max_depth))
892891

893-
result = tuple((kv[0], _parse_async_node(kv[1])) for kv in _members)
894-
return result
892+
return tuple((kv[0], _parse_async_node(kv[1])) for kv in _members)
895893

896894
def __contains__(self, member: str) -> bool:
897895
return self._sync(self._async_group.contains(member))

src/zarr/store/common.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def _dereference_path(root: str, path: str) -> str:
2323
assert isinstance(path, str)
2424
root = root.rstrip("/")
2525
path = f"{root}/{path}" if root else path
26-
path = path.rstrip("/")
27-
return path
26+
return path.rstrip("/")
2827

2928

3029
class StorePath:
@@ -66,7 +65,7 @@ def __repr__(self) -> str:
6665

6766
def __eq__(self, other: object) -> bool:
6867
try:
69-
return bool(self.store == other.store and self.path == other.path) # type: ignore[attr-defined]
68+
return self.store == other.store and self.path == other.path # type: ignore[attr-defined]
7069
except Exception:
7170
pass
7271
return False
@@ -265,8 +264,7 @@ async def contains_array(store_path: StorePath, zarr_format: ZarrFormat) -> bool
265264
except (ValueError, KeyError):
266265
return False
267266
elif zarr_format == 2:
268-
result = await (store_path / ZARRAY_JSON).exists()
269-
return result
267+
return await (store_path / ZARRAY_JSON).exists()
270268
msg = f"Invalid zarr_format provided. Got {zarr_format}, expected 2 or 3"
271269
raise ValueError(msg)
272270

src/zarr/store/memory.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ async def get_partial_values(
8080
async def _get(key: str, byte_range: tuple[int, int | None]) -> Buffer | None:
8181
return await self.get(key, prototype=prototype, byte_range=byte_range)
8282

83-
vals = await concurrent_map(key_ranges, _get, limit=None)
84-
return vals
83+
return await concurrent_map(key_ranges, _get, limit=None)
8584

8685
async def exists(self, key: str) -> bool:
8786
return key in self._store_dict

src/zarr/testing/strategies.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,4 @@ def key_ranges(keys: SearchStrategy = node_names) -> SearchStrategy[list]:
171171
st.none() | st.integers(min_value=0), st.none() | st.integers(min_value=0)
172172
)
173173
key_tuple = st.tuples(keys, byte_ranges)
174-
key_range_st = st.lists(key_tuple, min_size=1, max_size=10)
175-
return key_range_st
174+
return st.lists(key_tuple, min_size=1, max_size=10)

0 commit comments

Comments
 (0)