Skip to content

Commit

Permalink
rename NoneSkipBase to SkipNoneBase
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Aug 29, 2024
1 parent af8c1ca commit 60163cc
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/pydantic_ome_ngff/base.py
Original file line number Diff line number Diff line change
@@ -18,21 +18,21 @@ class VersionedBase(pydantic.BaseModel):
_version: str = "0.0"


class NoneSkipBase(pydantic.BaseModel):
class SkipNoneBase(pydantic.BaseModel):
_skip_if_none: tuple[str, ...] = ()

@pydantic.model_serializer(mode="wrap")
def serialize(
self: Self,
serializer: Callable[[NoneSkipBase], dict[str, Any]],
serializer: Callable[[SkipNoneBase], dict[str, Any]],
info: pydantic.SerializationInfo,
) -> dict[str, Any]:
return skip_none(self, serializer, info)


def skip_none(
self: NoneSkipBase,
serializer: Callable[[NoneSkipBase], dict[str, Any]],
self: SkipNoneBase,
serializer: Callable[[SkipNoneBase], dict[str, Any]],
info: pydantic.SerializationInfo,
) -> dict[str, Any]:
"""
4 changes: 2 additions & 2 deletions src/pydantic_ome_ngff/v04/axis.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
from enum import Enum


from pydantic_ome_ngff.base import FrozenBase, NoneSkipBase
from pydantic_ome_ngff.base import FrozenBase, SkipNoneBase
from pydantic_ome_ngff.v04.base import version


@@ -123,7 +123,7 @@ def check_type_unit(model: Axis) -> Axis:
return model


class Axis(NoneSkipBase, FrozenBase):
class Axis(SkipNoneBase, FrozenBase):
"""
Axis metadata.
4 changes: 2 additions & 2 deletions src/pydantic_ome_ngff/v04/multiscale.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
from zarr.util import guess_chunks

import pydantic_ome_ngff.v04.transform as tx
from pydantic_ome_ngff.base import FrozenBase, NoneSkipBase, VersionedBase
from pydantic_ome_ngff.base import FrozenBase, SkipNoneBase, VersionedBase
from pydantic_ome_ngff.utils import (
ArrayLike,
ChunkedArrayLike,
@@ -184,7 +184,7 @@ def ensure_axis_types(axes: Sequence[Axis]) -> Sequence[Axis]:
return axes


class MultiscaleMetadata(VersionedBase, FrozenBase, NoneSkipBase):
class MultiscaleMetadata(VersionedBase, FrozenBase, SkipNoneBase):
"""
Multiscale image metadata.
4 changes: 2 additions & 2 deletions tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
import pydantic
from pydantic_ome_ngff.base import FrozenBase, VersionedBase, NoneSkipBase
from pydantic_ome_ngff.base import FrozenBase, VersionedBase, SkipNoneBase


def test_frozen_base() -> None:
@@ -19,7 +19,7 @@ class X(VersionedBase): ...


def test_noneskipbase() -> None:
class X(NoneSkipBase):
class X(SkipNoneBase):
_skip_if_none = ("a", "b")
a: int | None
b: int

0 comments on commit 60163cc

Please sign in to comment.