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

Enforce ruff/refurb rules (FURB) #2373

Open
wants to merge 3 commits into
base: main
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
37 changes: 20 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -207,30 +207,33 @@ extend-exclude = [

[tool.ruff.lint]
extend-select = [
"ANN", # flake8-annotations
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"FLY", # flynt
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RET", # flake8-return
"ANN", # flake8-annotations
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"FLY", # flynt
"FURB", # refurb
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RSE", # flake8-raise
"RET", # flake8-return
"RUF",
"TCH", # flake8-type-checking
"TRY", # tryceratops
"UP", # pyupgrade
"TCH", # flake8-type-checking
"TRY", # tryceratops
"UP", # pyupgrade
]
ignore = [
"ANN003",
"ANN101",
"ANN102",
"ANN401",
"PT004", # deprecated
"PT011", # TODO: apply this rule
"PT012", # TODO: apply this rule
"FURB118", # TODO: apply this rule
"FURB140", # TODO: apply this rule
"PT004", # deprecated
"PT011", # TODO: apply this rule
"PT012", # TODO: apply this rule
"PYI013",
"RET505",
"RET506",
Expand Down
4 changes: 2 additions & 2 deletions src/zarr/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ def __init__(
chunks_multi_index_broadcast = np.broadcast_arrays(*chunks_multi_index)

# remember shape of selection, because we will flatten indices for processing
sel_shape = selection_broadcast[0].shape if selection_broadcast[0].shape else (1,)
sel_shape = selection_broadcast[0].shape or (1,)

# flatten selection
selection_broadcast = tuple(dim_sel.reshape(-1) for dim_sel in selection_broadcast)
Expand All @@ -1150,7 +1150,7 @@ def __init__(
else:
sel_sort = None

shape = selection_broadcast[0].shape if selection_broadcast[0].shape else (1,)
shape = selection_broadcast[0].shape or (1,)

# precompute number of selected items for each chunk
chunk_nitems = np.bincount(chunks_raveled_indices, minlength=nchunks)
Expand Down
3 changes: 1 addition & 2 deletions src/zarr/storage/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:

async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
# docstring inherited
if prefix.endswith("/"):
prefix = prefix[:-1]
prefix = prefix.removesuffix("/")

if prefix == "":
keys_unique = {k.split("/")[0] for k in self._store_dict}
Expand Down
3 changes: 1 addition & 2 deletions src/zarr/storage/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ async def list_prefix(self, prefix: str) -> AsyncGenerator[str, None]:

async def list_dir(self, prefix: str) -> AsyncGenerator[str, None]:
# docstring inherited
if prefix.endswith("/"):
prefix = prefix[:-1]
prefix = prefix.removesuffix("/")

keys = self._zf.namelist()
seen = set()
Expand Down