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

Drop py39 #38

Merged
merged 2 commits into from
Aug 29, 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python
Expand Down
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ except ValidationError as e:
print(e)
"""
1 validation error for Group
Value error, Dataset s0 was specified in multiscale metadata, but no array with that name was found in the hierarchy. All arrays referenced in multiscale metadata must be contained in the group. [type=value_error, input_value={'zarr_version': 2, 'attr...: 'zstd', 'level': 3}}}}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.7/v/value_error
Value error, Dataset s0 was specified in multiscale metadata, but no array with that name was found in the hierarchy. All arrays referenced in multiscale metadata must be contained in the group. [type=value_error, input_value={'zarr_version': 2, 'attr...3, 'checksum': False}}}}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.8/v/value_error
"""

group_model_wrong_array = group_model.model_dump()
Expand All @@ -481,7 +481,7 @@ except ValidationError as e:
print(e)
"""
1 validation error for Group
Value error, Transform type='scale' scale=(1, 1) has dimensionality 2, which does not match the dimensionality of the array found in this group at s0 (1). Transform dimensionality must match array dimensionality. [type=value_error, input_value={'zarr_version': 2, 'attr...: 'zstd', 'level': 3}}}}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.7/v/value_error
Value error, Transform type='scale' scale=(1, 1) has dimensionality 2, which does not match the dimensionality of the array found in this group at s0 (1). Transform dimensionality must match array dimensionality. [type=value_error, input_value={'zarr_version': 2, 'attr...3, 'checksum': False}}}}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.8/v/value_error
"""
```
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Source = "https://github.com/janeliascicomp/pydantic-ome-ngff"
version.source = "vcs"
build.hooks.vcs.version-file = "src/pydantic_ome_ngff/_version.py"

[tool.hatch.envs.default]
installer = "uv"

[tool.hatch.envs.test]
dependencies = [
"pytest==8.0.0",
Expand All @@ -51,7 +54,7 @@ run = "run-coverage --no-cov"
run-verbose = "run-coverage --verbose"

[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.10", "3.11"]
python = ["3.10", "3.11", "3.12"]

[tool.hatch.envs.types]
extra-dependencies = [
Expand Down
8 changes: 3 additions & 5 deletions src/pydantic_ome_ngff/latest/transform.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from typing import Union

import pydantic_ome_ngff.v04.transform as tx


Expand Down Expand Up @@ -40,9 +38,9 @@ class VectorScale(tx.VectorScale):
"""


Scale = Union[VectorScale, PathScale]
Translation = Union[VectorTranslation, PathTranslation]
Transform = Union[Scale, Translation, Identity]
Scale = VectorScale | PathScale
Translation = VectorTranslation | PathTranslation
Transform = Scale | Translation | Identity

scale_translation = tx.scale_translation
ensure_dimensionality = tx.ensure_dimensionality
Expand Down
6 changes: 3 additions & 3 deletions src/pydantic_ome_ngff/v04/multiscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from numcodecs.abc import Codec
from typing_extensions import Self

from typing import Annotated, Any, Sequence, Union, cast
from typing import Annotated, Any, Sequence, cast

import zarr
from numcodecs import Zstd
Expand Down Expand Up @@ -264,7 +264,7 @@ class GroupAttrs(BaseModel):
multiscales: Annotated[tuple[MultiscaleMetadata, ...], Field(..., min_length=1)]


class Group(GroupSpec[GroupAttrs, Union[ArraySpec, GroupSpec]]):
class Group(GroupSpec[GroupAttrs, ArraySpec | GroupSpec]):
"""
A model of a Zarr group that implements OME-NGFF Multiscales metadata.

Expand Down Expand Up @@ -479,7 +479,7 @@ def check_array_ndim(self) -> Group:
for tform in tforms:
if hasattr(tform, "scale") or hasattr(tform, "translation"):
tform = cast(
Union[tx.VectorScale, tx.VectorTranslation],
tx.VectorScale | tx.VectorTranslation,
tform,
)
if (tform_ndim := tx.ndim(tform)) != arr_ndim:
Expand Down
4 changes: 1 addition & 3 deletions src/pydantic_ome_ngff/v04/plate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from typing import Union

from pydantic import (
BaseModel,
NonNegativeInt,
Expand Down Expand Up @@ -54,7 +52,7 @@ class GroupAttrs(BaseModel):
plate: PlateMetadata


class Group(GroupSpec[GroupAttrs, Union[well.Group, GroupSpec, ArraySpec]]):
class Group(GroupSpec[GroupAttrs, well.Group | GroupSpec | ArraySpec]):
@field_validator("members", mode="after")
@classmethod
def contains_well_group(
Expand Down
8 changes: 4 additions & 4 deletions src/pydantic_ome_ngff/v04/transform.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Annotated, Literal, Sequence, Union
from typing import Annotated, Literal, Sequence

from pydantic_ome_ngff.base import StrictBase

Expand Down Expand Up @@ -166,9 +166,9 @@ def scale_translation(
return (vec_scale, vec_trans)


Scale = Union[VectorScale, PathScale]
Translation = Union[VectorTranslation, PathTranslation]
Transform = Union[Scale, Translation]
Scale = VectorScale | PathScale
Translation = VectorTranslation | PathTranslation
Transform = Scale | Translation


def ensure_dimensionality(
Expand Down
3 changes: 1 addition & 2 deletions src/pydantic_ome_ngff/v04/well.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from typing import Union
from pydantic import BaseModel, ValidationError, field_validator
from pydantic_zarr.v2 import ArraySpec, GroupSpec

Expand Down Expand Up @@ -29,7 +28,7 @@ class GroupAttrs(BaseModel):
well: WellMetadata


class Group(GroupSpec[GroupAttrs, Union[multiscale.Group, GroupSpec, ArraySpec]]):
class Group(GroupSpec[GroupAttrs, multiscale.Group | GroupSpec | ArraySpec]):
@field_validator("members", mode="after")
@classmethod
def contains_multiscale_group(
Expand Down