Skip to content

Commit

Permalink
Add recommended mypy config (#71)
Browse files Browse the repository at this point in the history
* Improve TOC structure

* Add recommended mypy config

* Add pytest to mypy deps

* Fix unreachable messages

* Add pydantic zarr to type checking

* Remove unused comments

* Add a py.typed file

* Ignore subclssing any warnings
  • Loading branch information
dstansby authored Dec 26, 2024
1 parent deb2169 commit d9d63dc
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@ repos:
rev: 0.7.21 # 0.7.19
hooks:
- id: mdformat

- repo: https://github.com/pre-commit/mirrors-mypy
rev: f56614daa94d5cd733d3b7004c5df9caad267b4a # 1.13.0
hooks:
- id: mypy
additional_dependencies:
- pydantic
- pytest
- pydantic-zarr
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ skip-magic-trailing-comma = false # default is false
[tool.mypy]

strict = true
warn_unreachable = true
plugins = ['pydantic.mypy']
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[[tool.mypy.overrides]]
module = ["zarr.*", "pydantic_zarr.*"]
Expand Down
Empty file added src/ome_zarr_models/py.typed
Empty file.
2 changes: 1 addition & 1 deletion src/ome_zarr_models/v04/hcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HCSAttrs(Base):
plate: Plate


class HCS(GroupSpec[HCSAttrs, ArraySpec | GroupSpec]):
class HCS(GroupSpec[HCSAttrs, ArraySpec | GroupSpec]): # type: ignore[misc]
"""
An OME-zarr high-content screening (HCS) dataset representing a single plate.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/ome_zarr_models/v04/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ImageAttrs(Base):
omero: Omero | None = None


class Image(GroupSpec[ImageAttrs, ArraySpec | GroupSpec]):
class Image(GroupSpec[ImageAttrs, ArraySpec | GroupSpec]): # type: ignore[misc]
"""
An OME-zarr multiscale dataset.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/ome_zarr_models/v04/image_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class ImageLabelAttrs(Base):
multiscales: list[Multiscale]


class ImageLabel(GroupSpec[ImageLabelAttrs, ArraySpec | GroupSpec]):
class ImageLabel(GroupSpec[ImageLabelAttrs, ArraySpec | GroupSpec]): # type: ignore[misc]
_check_arrays_compatible = model_validator(mode="after")(_check_arrays_compatible)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion src/ome_zarr_models/v04/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LabelsAttrs(Base):
)


class Labels(GroupSpec[LabelsAttrs, ArraySpec | GroupSpec]):
class Labels(GroupSpec[LabelsAttrs, ArraySpec | GroupSpec]): # type: ignore[misc]
"""
An OME-zarr labels dataset.
"""
2 changes: 1 addition & 1 deletion src/ome_zarr_models/v04/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class WellAttrs(Base):
well: Well


class WellGroup(GroupSpec[WellAttrs, ArraySpec | GroupSpec]):
class WellGroup(GroupSpec[WellAttrs, ArraySpec | GroupSpec]): # type: ignore[misc]
def get_image(self, i: int) -> Image:
"""
Get a single image from this well.
Expand Down
2 changes: 1 addition & 1 deletion tests/v04/test_multiscales.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def test_transform_invalid_second_element(
match="The second element of `coordinateTransformations` "
"must be a translation transform",
):
Dataset(path="foo", coordinateTransformations=transforms) # type: ignore[arg-type]
Dataset(path="foo", coordinateTransformations=transforms)


def test_validate_axes_top_transforms() -> None:
Expand Down

0 comments on commit d9d63dc

Please sign in to comment.