Skip to content

Apply new ruff rules (preview mode) #2235

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

Merged
merged 4 commits into from
Sep 27, 2024
Merged
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
8 changes: 4 additions & 4 deletions src/zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
assert not __version__.startswith("0.0.0")

__all__ = [
"__version__",
"config",
"Array",
"AsyncArray",
"Group",
"AsyncGroup",
"tree",
"Group",
"__version__",
"array",
"config",
"consolidate_metadata",
"copy",
"copy_all",
Expand All @@ -63,6 +62,7 @@
"save",
"save_array",
"save_group",
"tree",
"zeros",
"zeros_like",
]
8 changes: 4 additions & 4 deletions src/zarr/abc/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@
from zarr.core.indexing import SelectorTuple

__all__ = [
"CodecInput",
"CodecOutput",
"ArrayArrayCodec",
"ArrayBytesCodec",
"BytesBytesCodec",
"ArrayBytesCodecPartialDecodeMixin",
"ArrayBytesCodecPartialEncodeMixin",
"BytesBytesCodec",
"CodecInput",
"CodecOutput",
"CodecPipeline",
]

CodecInput = TypeVar("CodecInput", bound=NDBuffer | Buffer)
CodecOutput = TypeVar("CodecOutput", bound=NDBuffer | Buffer)


class _Codec(Generic[CodecInput, CodecOutput], Metadata):
class _Codec(Metadata, Generic[CodecInput, CodecOutput]):
"""Generic base class for codecs.
Please use ArrayArrayCodec, ArrayBytesCodec or BytesBytesCodec for subclassing.

Expand Down
2 changes: 1 addition & 1 deletion src/zarr/abc/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from zarr.core.buffer import Buffer, BufferPrototype
from zarr.core.common import AccessModeLiteral, BytesLike

__all__ = ["Store", "AccessMode", "ByteGetter", "ByteSetter", "set_or_delete"]
__all__ = ["AccessMode", "ByteGetter", "ByteSetter", "Store", "set_or_delete"]


class AccessMode(NamedTuple):
Expand Down
20 changes: 10 additions & 10 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,29 @@
PathLike = str

__all__ = [
"array",
"consolidate_metadata",
"copy",
"copy_all",
"copy_store",
"load",
"open",
"open_consolidated",
"save",
"save_array",
"save_group",
"tree",
"array",
"group",
"open_group",
"create",
"empty",
"empty_like",
"full",
"full_like",
"group",
"load",
"ones",
"ones_like",
"open",
"open_array",
"open_consolidated",
"open_group",
"open_like",
"save",
"save_array",
"save_group",
"tree",
"zeros",
"zeros_like",
]
Expand Down
20 changes: 10 additions & 10 deletions src/zarr/api/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@
from zarr.store import StoreLike

__all__ = [
"array",
"consolidate_metadata",
"copy",
"copy_all",
"copy_store",
"load",
"open",
"open_consolidated",
"save",
"save_array",
"save_group",
"tree",
"array",
"group",
"open_group",
"create",
"empty",
"empty_like",
"full",
"full_like",
"group",
"load",
"ones",
"ones_like",
"open",
"open_array",
"open_consolidated",
"open_group",
"open_like",
"save",
"save_array",
"save_group",
"tree",
"zeros",
"zeros_like",
]
Expand Down
12 changes: 6 additions & 6 deletions src/zarr/convenience.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
)

__all__ = [
"consolidate_metadata",
"copy",
"copy_all",
"copy_store",
"load",
"open",
"open_consolidated",
"save",
"load",
"save_array",
"save_group",
"copy",
"copy_all",
"copy_store",
"tree",
"consolidate_metadata",
"open_consolidated",
]

warnings.warn(
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
from zarr.core.metadata.common import ArrayMetadata

# Array and AsyncArray are defined in the base ``zarr`` namespace
__all__ = ["parse_array_metadata", "create_codec_pipeline"]
__all__ = ["create_codec_pipeline", "parse_array_metadata"]


def parse_array_metadata(data: Any) -> ArrayV2Metadata | ArrayV3Metadata:
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/core/buffer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
__all__ = [
"ArrayLike",
"Buffer",
"BufferPrototype",
"NDArrayLike",
"NDBuffer",
"BufferPrototype",
"default_buffer_prototype",
"numpy_buffer_prototype",
]
2 changes: 1 addition & 1 deletion src/zarr/core/buffer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def all_equal(self, other: Any, equal_nan: bool = True) -> bool:
# Handle None fill_value for Zarr V2
return False
# use array_equal to obtain equal_nan=True functionality
data, other = np.broadcast_arrays(self._data, other)
_data, other = np.broadcast_arrays(self._data, other)
return np.array_equal(
self._data, other, equal_nan=equal_nan if self._data.dtype.kind not in "US" else False
)
Expand Down
14 changes: 7 additions & 7 deletions src/zarr/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
)

__all__ = [
"array",
"create",
"empty",
"zeros",
"ones",
"full",
"array",
"open_array",
"empty_like",
"zeros_like",
"ones_like",
"full",
"full_like",
"ones",
"ones_like",
"open_array",
"open_like",
"zeros",
"zeros_like",
]

warnings.warn(
Expand Down
4 changes: 2 additions & 2 deletions src/zarr/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ContainsArrayAndGroupError(_BaseZarrError):


__all__ = [
"ContainsGroupError",
"ContainsArrayError",
"ContainsArrayAndGroupError",
"ContainsArrayError",
"ContainsGroupError",
]
14 changes: 7 additions & 7 deletions src/zarr/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@

__all__ = [
"Registry",
"register_codec",
"register_pipeline",
"register_buffer",
"register_ndbuffer",
"get_codec_class",
"get_pipeline_class",
"get_buffer_class",
"get_codec_class",
"get_ndbuffer_class",
"get_pipeline_class",
"register_buffer",
"register_codec",
"register_ndbuffer",
"register_pipeline",
]

T = TypeVar("T")


class Registry(Generic[T], dict[str, type[T]]):
class Registry(dict[str, type[T]], Generic[T]):
def __init__(self) -> None:
super().__init__()
self.lazy_load_list: list[EntryPoint] = []
Expand Down
8 changes: 4 additions & 4 deletions src/zarr/store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from zarr.store.zip import ZipStore

__all__ = [
"StorePath",
"StoreLike",
"make_store_path",
"RemoteStore",
"LocalStore",
"MemoryStore",
"RemoteStore",
"StoreLike",
"StorePath",
"ZipStore",
"make_store_path",
]
2 changes: 1 addition & 1 deletion src/zarr/store/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _is_fsspec_uri(uri: str) -> bool:
>>> _is_fsspec_uri("local://my-directory")
False
"""
return "://" in uri or "::" in uri and "local://" not in uri
return "://" in uri or ("::" in uri and "local://" not in uri)


async def ensure_no_existing_node(store_path: StorePath, zarr_format: ZarrFormat) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/testing/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@


__all__ = [
"TestBuffer",
"NDBufferUsingTestNDArrayLike",
"StoreExpectingTestBuffer",
"TestBuffer",
]


Expand Down