Skip to content

Commit 1d9658b

Browse files
Enforce ruff/flake8-return rules (RET) (zarr-developers#2237)
* Apply ruff/flake8-return rule RET501 RET501 Do not explicitly `return None` in function if it is the only possible return value * Apply ruff/flake8-return rule RET504 RET504 Unnecessary assignment before `return` statement * Enforce ruff/flake8-return rules (RET)
1 parent 1569eca commit 1d9658b

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,16 @@ extend-select = [
214214
"PGH", # pygrep-hooks
215215
"PYI", # flake8-pyi
216216
"RSE", # flake8-raise
217+
"RET", # flake8-return
217218
"RUF",
218219
"TCH", # flake8-type-checking
219220
"TRY", # tryceratops
220221
"UP", # pyupgrade
221222
]
222223
ignore = [
223224
"PYI013",
225+
"RET505",
226+
"RET506",
224227
"RUF005",
225228
"TRY003",
226229
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules

src/zarr/abc/store.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ async def _set_many(self, values: Iterable[tuple[str, Buffer]]) -> None:
170170
Insert multiple (key, value) pairs into storage.
171171
"""
172172
await gather(*(self.set(key, value) for key, value in values))
173-
return None
173+
return
174174

175175
@property
176176
@abstractmethod

src/zarr/core/buffer/core.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,9 @@ def all_equal(self, other: Any, equal_nan: bool = True) -> bool:
469469
return False
470470
# use array_equal to obtain equal_nan=True functionality
471471
data, other = np.broadcast_arrays(self._data, other)
472-
result = np.array_equal(
472+
return np.array_equal(
473473
self._data, other, equal_nan=equal_nan if self._data.dtype.kind not in "US" else False
474474
)
475-
return result
476475

477476
def fill(self, value: Any) -> None:
478477
self._data.fill(value)

tests/v3/conftest.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ def path_type(request: pytest.FixtureRequest) -> Any:
4646
@pytest.fixture
4747
async def store_path(tmpdir: LEGACY_PATH) -> StorePath:
4848
store = await LocalStore.open(str(tmpdir), mode="w")
49-
p = StorePath(store)
50-
return p
49+
return StorePath(store)
5150

5251

5352
@pytest.fixture(scope="function")
@@ -88,13 +87,12 @@ async def async_group(request: pytest.FixtureRequest, tmpdir: LEGACY_PATH) -> As
8887
param: AsyncGroupRequest = request.param
8988

9089
store = await parse_store(param.store, str(tmpdir))
91-
agroup = await AsyncGroup.from_store(
90+
return await AsyncGroup.from_store(
9291
store,
9392
attributes=param.attributes,
9493
zarr_format=param.zarr_format,
9594
exists_ok=False,
9695
)
97-
return agroup
9896

9997

10098
@pytest.fixture(params=["numpy", "cupy"])

tests/v3/test_store/test_stateful_store.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,12 @@ def list(self) -> list:
4040
return self._sync_iter(self.store.list())
4141

4242
def get(self, key: str, prototype: BufferPrototype) -> zarr.core.buffer.Buffer:
43-
obs = self._sync(self.store.get(key, prototype=prototype))
44-
return obs
43+
return self._sync(self.store.get(key, prototype=prototype))
4544

4645
def get_partial_values(
4746
self, key_ranges: list, prototype: BufferPrototype
4847
) -> zarr.core.buffer.Buffer:
49-
obs_partial = self._sync(
50-
self.store.get_partial_values(prototype=prototype, key_ranges=key_ranges)
51-
)
52-
return obs_partial
48+
return self._sync(self.store.get_partial_values(prototype=prototype, key_ranges=key_ranges))
5349

5450
def delete(self, path: str) -> None:
5551
return self._sync(self.store.delete(path))

0 commit comments

Comments
 (0)