Skip to content

Commit

Permalink
Merge pull request #270 from will-moore/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
Pre commit ci update config
  • Loading branch information
jburel authored Apr 7, 2023
2 parents 6edeaaf + abd65ef commit 0181bb4
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 67 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.3.0
hooks:
- id: black
args: [--target-version=py36]

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- --py36-plus

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: .bumpversion.cfg
Expand All @@ -45,7 +45,7 @@ repos:
- --autofix

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: [
Expand All @@ -64,12 +64,12 @@ repos:
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v1.1.1
hooks:
- id: mypy

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v1.1.1
hooks:
- id: mypy
args: [
Expand All @@ -79,7 +79,7 @@ repos:
exclude: tests/|setup.py

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0
rev: v1.30.0
hooks:
- id: yamllint
# args: [--config-data=relaxed]
Expand Down
1 change: 0 additions & 1 deletion ome_zarr/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def _get_names(self) -> List[str]:
return axes_names

def _validate_03(self) -> None:

val_axes = tuple(self._get_names())
if len(val_axes) == 2:
if val_axes != ("y", "x"):
Expand Down
2 changes: 1 addition & 1 deletion ome_zarr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def csv_to_labels(args: argparse.Namespace) -> None:
csv_to_zarr(args.csv_path, args.csv_id, args.csv_keys, args.zarr_path, args.zarr_id)


def main(args: List[str] = None) -> None:
def main(args: List[str]) -> None:
"""Run appropriate function with argparse arguments, handling errors."""
parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down
1 change: 0 additions & 1 deletion ome_zarr/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def dict_to_zarr(
labels_paths.append(os.path.join(zarr_path, "labels", "0"))

for path_to_labels in labels_paths:

label_group = zarr_open(path_to_labels)
attrs = label_group.attrs.asdict()
properties = attrs.get("image-label", {}).get("properties")
Expand Down
5 changes: 2 additions & 3 deletions ome_zarr/data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Functions for generating synthetic data."""
from random import randrange
from typing import Callable, List, Tuple, Union
from typing import Callable, List, Optional, Tuple, Union

import numpy as np
import zarr
Expand Down Expand Up @@ -103,7 +103,7 @@ def create_zarr(
method: Callable[..., Tuple[List, List]] = coins,
label_name: str = "coins",
fmt: Format = CurrentFormat(),
chunks: Union[Tuple, List] = None,
chunks: Optional[Union[Tuple, List]] = None,
) -> zarr.Group:
"""Generate a synthetic image pyramid with labels."""
pyramid, labels = method()
Expand Down Expand Up @@ -170,7 +170,6 @@ def create_zarr(
grp.attrs["omero"] = image_data

if labels:

labels_grp = grp.create_group("labels")
labels_grp.attrs["labels"] = [label_name]

Expand Down
9 changes: 3 additions & 6 deletions ome_zarr/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@


def format_from_version(version: str) -> "Format":

for fmt in format_implementations():

# Support floating-point versions like `0.2`
if isinstance(version, float):
version = str(version)
Expand Down Expand Up @@ -110,7 +108,7 @@ def validate_coordinate_transformations(
self,
ndim: int,
nlevels: int,
coordinate_transformations: List[List[Dict[str, Any]]] = None,
coordinate_transformations: Optional[List[List[Dict[str, Any]]]] = None,
) -> Optional[List[List[Dict[str, Any]]]]: # pragma: no cover
raise NotImplementedError()

Expand Down Expand Up @@ -163,7 +161,7 @@ def validate_coordinate_transformations(
self,
ndim: int,
nlevels: int,
coordinate_transformations: List[List[Dict[str, Any]]] = None,
coordinate_transformations: Optional[List[List[Dict[str, Any]]]] = None,
) -> None:
return None

Expand Down Expand Up @@ -258,7 +256,6 @@ def validate_well_dict(
def generate_coordinate_transformations(
self, shapes: List[tuple]
) -> Optional[List[List[Dict[str, Any]]]]:

data_shape = shapes[0]
coordinate_transformations: List[List[Dict[str, Any]]] = []
# calculate minimal 'scale' transform based on pyramid dims
Expand All @@ -273,7 +270,7 @@ def validate_coordinate_transformations(
self,
ndim: int,
nlevels: int,
coordinate_transformations: List[List[Dict[str, Any]]] = None,
coordinate_transformations: Optional[List[List[Dict[str, Any]]]] = None,
) -> None:
"""
Validates that a list of dicts contains a 'scale' transformation
Expand Down
1 change: 0 additions & 1 deletion ome_zarr/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class ZarrLocation:
def __init__(
self, path: Union[Path, str], mode: str = "r", fmt: Format = CurrentFormat()
) -> None:

LOGGER.debug("ZarrLocation.__init__ path: %s, fmt: %s", path, fmt.version)
self.__fmt = fmt
self.__mode = mode
Expand Down
2 changes: 0 additions & 2 deletions ome_zarr/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ def __init__(self, zarr: ZarrLocation) -> None:
def __call__(self) -> Iterator[Node]:
node = Node(self.zarr, self)
if node.specs: # Something has matched

LOGGER.debug("treating %s as ome-zarr", self.zarr)
yield from self.descend(node)

Expand All @@ -642,7 +641,6 @@ def __call__(self) -> Iterator[Node]:
# yield nothing

def descend(self, node: Node, depth: int = 0) -> Iterator[Node]:

for pre_node in node.pre_nodes:
yield from self.descend(pre_node, depth + 1)

Expand Down
2 changes: 0 additions & 2 deletions ome_zarr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def info(path: str, stats: bool = False) -> Iterator[Node]:
assert zarr, f"not a zarr: {zarr}"
reader = Reader(zarr)
for node in reader():

if not node.specs:
print(f"not an ome-zarr node: {node}")
continue
Expand Down Expand Up @@ -73,7 +72,6 @@ def download(input_path: str, output_dir: str = ".") -> None:
print(f"to {output_dir}")

for path, node in sorted(zip(paths, nodes)):

target_path = output_path / Path(*path)
target_path.mkdir(parents=True)

Expand Down
72 changes: 33 additions & 39 deletions ome_zarr/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@


def _get_valid_axes(
ndim: int = None,
axes: Union[str, List[str], List[Dict[str, str]]] = None,
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]]]:
"""Returns list of axes valid for fmt.version or raise exception if invalid"""
Expand Down Expand Up @@ -64,7 +64,6 @@ def _get_valid_axes(
def _validate_well_images(
images: List[Union[str, dict]], fmt: Format = CurrentFormat()
) -> List[dict]:

VALID_KEYS = [
"acquisition",
"path",
Expand All @@ -91,7 +90,6 @@ def _validate_well_images(
def _validate_plate_acquisitions(
acquisitions: List[Dict], fmt: Format = CurrentFormat()
) -> List[Dict]:

VALID_KEYS = [
"id",
"name",
Expand All @@ -117,7 +115,6 @@ def _validate_plate_rows_columns(
rows_or_columns: List[str],
fmt: Format = CurrentFormat(),
) -> List[dict]:

if len(set(rows_or_columns)) != len(rows_or_columns):
raise ValueError(f"{rows_or_columns} must contain unique elements")
validated_list = []
Expand All @@ -131,7 +128,6 @@ def _validate_plate_rows_columns(
def _validate_datasets(
datasets: List[dict], dims: int, fmt: Format = CurrentFormat()
) -> List[Dict]:

if datasets is None or len(datasets) == 0:
raise ValueError("Empty datasets list")
transformations = []
Expand All @@ -156,7 +152,6 @@ def _validate_plate_wells(
columns: List[str],
fmt: Format = CurrentFormat(),
) -> List[dict]:

validated_wells = []
if wells is None or len(wells) == 0:
raise ValueError("Empty wells list")
Expand All @@ -176,12 +171,12 @@ def _validate_plate_wells(
def write_multiscale(
pyramid: ListOfArrayLike,
group: zarr.Group,
chunks: Union[Tuple[Any, ...], int] = None,
chunks: Optional[Union[Tuple[Any, ...], int]] = None,
fmt: Format = CurrentFormat(),
axes: Union[str, List[str], List[Dict[str, str]]] = None,
coordinate_transformations: List[List[Dict[str, Any]]] = None,
storage_options: Union[JSONDict, List[JSONDict]] = None,
name: str = None,
axes: Optional[Union[str, List[str], List[Dict[str, str]]]] = None,
coordinate_transformations: Optional[List[List[Dict[str, Any]]]] = None,
storage_options: Optional[Union[JSONDict, List[JSONDict]]] = None,
name: Optional[str] = None,
**metadata: Union[str, JSONDict, List[JSONDict]],
) -> None:
"""
Expand Down Expand Up @@ -277,8 +272,8 @@ def write_multiscales_metadata(
group: zarr.Group,
datasets: List[dict],
fmt: Format = CurrentFormat(),
axes: Union[str, List[str], List[Dict[str, str]]] = None,
name: str = None,
axes: Optional[Union[str, List[str], List[Dict[str, str]]]] = None,
name: Optional[str] = None,
**metadata: Union[str, JSONDict, List[JSONDict]],
) -> None:
"""
Expand Down Expand Up @@ -334,9 +329,9 @@ def write_plate_metadata(
columns: List[str],
wells: List[Union[str, dict]],
fmt: Format = CurrentFormat(),
acquisitions: List[dict] = None,
field_count: int = None,
name: str = None,
acquisitions: Optional[List[dict]] = None,
field_count: Optional[int] = None,
name: Optional[str] = None,
) -> None:
"""
Write the plate metadata in the group.
Expand Down Expand Up @@ -405,11 +400,11 @@ def write_image(
image: ArrayLike,
group: zarr.Group,
scaler: Scaler = Scaler(),
chunks: Union[Tuple[Any, ...], int] = None,
chunks: Optional[Union[Tuple[Any, ...], int]] = None,
fmt: Format = CurrentFormat(),
axes: Union[str, List[str], List[Dict[str, str]]] = None,
coordinate_transformations: List[List[Dict[str, Any]]] = None,
storage_options: Union[JSONDict, List[JSONDict]] = None,
axes: Optional[Union[str, List[str], List[Dict[str, str]]]] = None,
coordinate_transformations: Optional[List[List[Dict[str, Any]]]] = None,
storage_options: Optional[Union[JSONDict, List[JSONDict]]] = None,
**metadata: Union[str, JSONDict, List[JSONDict]],
) -> None:
"""Writes an image to the zarr store according to ome-zarr specification
Expand Down Expand Up @@ -497,15 +492,14 @@ def _write_dask_image(
image: da.Array,
group: zarr.Group,
scaler: Scaler = Scaler(),
chunks: Union[Tuple[Any, ...], int] = None,
chunks: Optional[Union[Tuple[Any, ...], int]] = None,
fmt: Format = CurrentFormat(),
axes: Union[str, List[str], List[Dict[str, str]]] = None,
coordinate_transformations: List[List[Dict[str, Any]]] = None,
storage_options: Union[JSONDict, List[JSONDict]] = None,
name: str = None,
axes: Optional[Union[str, List[str], List[Dict[str, str]]]] = None,
coordinate_transformations: Optional[List[List[Dict[str, Any]]]] = None,
storage_options: Optional[Union[JSONDict, List[JSONDict]]] = None,
name: Optional[str] = None,
**metadata: Union[str, JSONDict, List[JSONDict]],
) -> None:

if fmt.version in ("0.1", "0.2"):
# v0.1 and v0.2 are strictly 5D
shape_5d: Tuple[Any, ...] = (*(1,) * (5 - image.ndim), *image.shape)
Expand Down Expand Up @@ -584,8 +578,8 @@ def _write_dask_image(
def write_label_metadata(
group: zarr.Group,
name: str,
colors: List[JSONDict] = None,
properties: List[JSONDict] = None,
colors: Optional[List[JSONDict]] = None,
properties: Optional[List[JSONDict]] = None,
fmt: Format = CurrentFormat(),
**metadata: Union[List[JSONDict], JSONDict, str],
) -> None:
Expand Down Expand Up @@ -633,12 +627,12 @@ def write_multiscale_labels(
pyramid: List,
group: zarr.Group,
name: str,
chunks: Union[Tuple[Any, ...], int] = None,
chunks: Optional[Union[Tuple[Any, ...], int]] = None,
fmt: Format = CurrentFormat(),
axes: Union[str, List[str], List[Dict[str, str]]] = None,
coordinate_transformations: List[List[Dict[str, Any]]] = None,
storage_options: Union[JSONDict, List[JSONDict]] = None,
label_metadata: JSONDict = None,
axes: Optional[Union[str, List[str], List[Dict[str, str]]]] = None,
coordinate_transformations: Optional[List[List[Dict[str, Any]]]] = None,
storage_options: Optional[Union[JSONDict, List[JSONDict]]] = None,
label_metadata: Optional[JSONDict] = None,
**metadata: JSONDict,
) -> None:
"""
Expand Down Expand Up @@ -710,12 +704,12 @@ def write_labels(
group: zarr.Group,
name: str,
scaler: Scaler = Scaler(),
chunks: Union[Tuple[Any, ...], int] = None,
chunks: Optional[Union[Tuple[Any, ...], int]] = None,
fmt: Format = CurrentFormat(),
axes: Union[str, List[str], List[Dict[str, str]]] = None,
coordinate_transformations: List[List[Dict[str, Any]]] = None,
storage_options: Union[JSONDict, List[JSONDict]] = None,
label_metadata: JSONDict = None,
axes: Optional[Union[str, List[str], List[Dict[str, str]]]] = None,
coordinate_transformations: Optional[List[List[Dict[str, Any]]]] = None,
storage_options: Optional[Union[JSONDict, List[JSONDict]]] = None,
label_metadata: Optional[JSONDict] = None,
**metadata: JSONDict,
) -> None:
"""
Expand Down
Loading

0 comments on commit 0181bb4

Please sign in to comment.