Skip to content

Commit 714ae2d

Browse files
committed
revert sentinel changes
1 parent 9e31126 commit 714ae2d

10 files changed

Lines changed: 49 additions & 35 deletions

File tree

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ warn_untyped_fields = true
172172
module = ["zarr.*", "xarray.*", "rioxarray.*", "cf_xarray.*", "dask.*"]
173173
ignore_missing_imports = true
174174

175+
[[tool.mypy.overrides]]
176+
module = [
177+
"eopf_geozarr.data_api.s1",
178+
"eopf_geozarr.data_api.s2",
179+
"eopf_geozarr.data_api.geozarr.v2",
180+
]
181+
disable_error_code = ["valid-type"]
182+
175183
[tool.pytest.ini_options]
176184
minversion = "7.0"
177185
addopts = "-ra -q --strict-markers --strict-config"

src/eopf_geozarr/data_api/geozarr/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from cf_xarray.utils import parse_cf_standard_name_table
2323
from pydantic import AfterValidator, BaseModel, Field, model_validator
2424
from pydantic.experimental.missing_sentinel import MISSING
25-
from typing_extensions import Sentinel, runtime_checkable
25+
from typing_extensions import runtime_checkable
2626

2727
from eopf_geozarr.data_api.geozarr.projjson import ProjJSON # noqa: TC001
2828

@@ -80,7 +80,7 @@ class BaseDataArrayAttrs(BaseModel, extra="allow"):
8080
----------
8181
"""
8282

83-
grid_mapping: str | Sentinel = MISSING
83+
grid_mapping: str | MISSING = MISSING # type: ignore[valid-type]
8484

8585

8686
class GridMappingAttrs(BaseModel, extra="allow"):

src/eopf_geozarr/data_api/geozarr/multiscales/geozarr.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pydantic import BaseModel, model_validator
66
from pydantic.experimental.missing_sentinel import MISSING
7-
from typing_extensions import Sentinel, TypedDict
7+
from typing_extensions import TypedDict
88
from zarr_cm import ConventionMetadataObject # noqa: TC002
99

1010
from . import tms, zcm
@@ -16,17 +16,17 @@ class MultiscaleMeta(BaseModel):
1616
or ZCM multiscale metadata
1717
"""
1818

19-
layout: tuple[zcm.ScaleLevel, ...] | Sentinel = MISSING
20-
resampling_method: str | Sentinel = MISSING
21-
tile_matrix_set: tms.TileMatrixSet | Sentinel = MISSING
22-
tile_matrix_limits: dict[str, tms.TileMatrixLimit] | Sentinel = MISSING
19+
layout: tuple[zcm.ScaleLevel, ...] | MISSING = MISSING # type: ignore[valid-type]
20+
resampling_method: str | MISSING = MISSING # type: ignore[valid-type]
21+
tile_matrix_set: tms.TileMatrixSet | MISSING = MISSING # type: ignore[valid-type]
22+
tile_matrix_limits: dict[str, tms.TileMatrixLimit] | MISSING = MISSING # type: ignore[valid-type]
2323

2424
@model_validator(mode="after")
2525
def valid_zcm(self) -> Self:
2626
"""
2727
Ensure that the ZCM metadata, if present, is valid
2828
"""
29-
if self.layout is not MISSING:
29+
if self.layout is not MISSING: # type: ignore[comparison-overlap]
3030
zcm.Multiscales(**self.model_dump())
3131

3232
return self
@@ -36,7 +36,7 @@ def valid_tms(self) -> Self:
3636
"""
3737
Ensure that the TMS metadata, if present, is valid
3838
"""
39-
if self.tile_matrix_set is not MISSING:
39+
if self.tile_matrix_set is not MISSING: # type: ignore[comparison-overlap]
4040
tms.Multiscales(**self.model_dump())
4141

4242
return self
@@ -55,7 +55,7 @@ class MultiscaleGroupAttrs(BaseModel):
5555
multiscales: MultiscaleAttrs
5656
"""
5757

58-
zarr_conventions: tuple[ConventionMetadataObject, ...] | Sentinel = MISSING
58+
zarr_conventions: tuple[ConventionMetadataObject, ...] | MISSING = MISSING # type: ignore[valid-type]
5959
multiscales: MultiscaleMeta
6060

6161
_zcm_multiscales: zcm.Multiscales | None = None
@@ -67,16 +67,16 @@ def valid_zcm_and_tms(self) -> Self:
6767
Ensure that the ZCM metadata, if present, is valid, and that TMS metadata, if present,
6868
is valid, and that at least one of the two is present.
6969
"""
70-
if self.zarr_conventions is not MISSING:
70+
if self.zarr_conventions is not MISSING: # type: ignore[comparison-overlap]
7171
self._zcm_multiscales = zcm.Multiscales(
72-
layout=self.multiscales.layout, # type: ignore[arg-type]
72+
layout=self.multiscales.layout,
7373
resampling_method=self.multiscales.resampling_method,
7474
)
75-
if self.multiscales.tile_matrix_limits is not MISSING:
75+
if self.multiscales.tile_matrix_limits is not MISSING: # type: ignore[comparison-overlap]
7676
self._tms_multiscales = tms.Multiscales(
77-
tile_matrix_limits=self.multiscales.tile_matrix_limits, # type: ignore[arg-type]
77+
tile_matrix_limits=self.multiscales.tile_matrix_limits,
7878
resampling_method=self.multiscales.resampling_method, # type: ignore[arg-type]
79-
tile_matrix_set=self.multiscales.tile_matrix_set, # type: ignore[arg-type]
79+
tile_matrix_set=self.multiscales.tile_matrix_set,
8080
)
8181
if self._tms_multiscales is None and self._zcm_multiscales is None:
8282
raise ValueError("Either ZCM multiscales or TMS multiscales must be present")

src/eopf_geozarr/data_api/geozarr/multiscales/zcm.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from pydantic import BaseModel, field_validator
44
from pydantic.experimental.missing_sentinel import MISSING
5-
from typing_extensions import Sentinel
65
from zarr_cm import ConventionMetadataObject
76
from zarr_cm import multiscales as multiscales_cm
87

@@ -27,22 +26,22 @@ class ZarrConventionAttrs(BaseModel):
2726

2827

2928
class Transform(BaseModel):
30-
scale: tuple[float, ...] | Sentinel = MISSING
31-
translation: tuple[float, ...] | Sentinel = MISSING
29+
scale: tuple[float, ...] | MISSING = MISSING # type: ignore[valid-type]
30+
translation: tuple[float, ...] | MISSING = MISSING # type: ignore[valid-type]
3231

3332

3433
class ScaleLevel(BaseModel):
3534
asset: str
36-
derived_from: str | Sentinel = MISSING
37-
transform: Transform | Sentinel = MISSING
38-
resampling_method: str | Sentinel = MISSING
35+
derived_from: str | MISSING = MISSING # type: ignore[valid-type]
36+
transform: Transform | MISSING = MISSING # type: ignore[valid-type]
37+
resampling_method: str | MISSING = MISSING # type: ignore[valid-type]
3938

4039
model_config = {"extra": "allow"}
4140

4241

4342
class Multiscales(BaseModel):
4443
layout: tuple[ScaleLevel, ...]
45-
resampling_method: str | Sentinel = MISSING
44+
resampling_method: str | MISSING = MISSING # type: ignore[valid-type]
4645

4746
model_config = {"extra": "allow"}
4847

src/eopf_geozarr/data_api/geozarr/v2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
if TYPE_CHECKING:
2121
from collections.abc import Iterable, Mapping
2222

23+
from pydantic.experimental.missing_sentinel import MISSING as MISSING
24+
2325

2426
class DataArrayAttrs(BaseDataArrayAttrs):
2527
"""

src/eopf_geozarr/data_api/s1.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
from __future__ import annotations
88

99
from collections.abc import Mapping
10-
from typing import Any
10+
from typing import TYPE_CHECKING, Any
1111

1212
from pydantic import BaseModel
1313
from typing_extensions import TypedDict
1414

15+
if TYPE_CHECKING:
16+
from pydantic.experimental.missing_sentinel import MISSING as MISSING
17+
1518
from eopf_geozarr.data_api.geozarr.common import (
1619
BaseDataArrayAttrs,
1720
CFStandardName,

src/eopf_geozarr/data_api/s2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66

77
from __future__ import annotations
88

9-
from typing import Annotated, Any, Literal
9+
from typing import TYPE_CHECKING, Annotated, Any, Literal
1010

1111
from pydantic import BaseModel, Field
1212
from typing_extensions import TypedDict
1313

14+
if TYPE_CHECKING:
15+
from pydantic.experimental.missing_sentinel import MISSING as MISSING
16+
1417
from eopf_geozarr.data_api.geozarr.common import (
1518
BaseDataArrayAttrs,
1619
CFStandardName,

src/eopf_geozarr/pyz/v2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class MyGroup(GroupSpec[Any, MyMembers])
2020
from __future__ import annotations
2121

2222
from collections.abc import Mapping
23-
from typing import Any, TypeVar
23+
from typing import Any, TypeAlias, TypeVar, Union
2424

2525
from pydantic_zarr.v2 import ArraySpec as ArraySpecV2
2626
from pydantic_zarr.v2 import GroupSpec as GroupSpecV2
@@ -33,7 +33,7 @@ class MyGroup(GroupSpec[Any, MyMembers])
3333
get_member_names,
3434
)
3535

36-
type TBaseMember = Mapping[str, "GroupSpec[Any, Any]" | "ArraySpec[Any]"]
36+
TBaseMember: TypeAlias = Mapping[str, Union["GroupSpec[Any, Any]", "ArraySpec[Any]"]] # noqa: UP040
3737

3838
TAttr = TypeVar("TAttr", bound=TBaseAttr)
3939
TMembers = TypeVar("TMembers", bound=TBaseMember)

src/eopf_geozarr/pyz/v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class MyGroup(GroupSpec[Any, MyMembers])
2020
from __future__ import annotations
2121

2222
from collections.abc import Mapping
23-
from typing import Any, TypeVar
23+
from typing import Any, TypeAlias, TypeVar, Union
2424

2525
from pydantic_zarr.v3 import ArraySpec as ArraySpecV3
2626
from pydantic_zarr.v3 import GroupSpec as GroupSpecV3
@@ -33,7 +33,7 @@ class MyGroup(GroupSpec[Any, MyMembers])
3333
get_member_names,
3434
)
3535

36-
type TBaseMember = Mapping[str, "GroupSpec[Any, Any]" | "ArraySpec[Any]"]
36+
TBaseMember: TypeAlias = Mapping[str, Union["GroupSpec[Any, Any]", "ArraySpec[Any]"]] # noqa: UP040
3737

3838
TAttr = TypeVar("TAttr", bound=TBaseAttr)
3939
TMembers = TypeVar("TMembers", bound=TBaseMember)

src/eopf_geozarr/s2_optimization/s2_multiscale.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from dask.array import from_delayed
1616
from pydantic.experimental.missing_sentinel import MISSING
1717
from pyproj import CRS
18-
from typing_extensions import Sentinel
1918
from zarr_cm import geo_proj
2019
from zarr_cm import multiscales as multiscales_cm
2120
from zarr_cm import spatial as spatial_cm
@@ -578,21 +577,21 @@ def add_multiscales_metadata_to_parent(
578577
return None
579578

580579
multiscales: dict[str, Any] = {"multiscales": {}}
581-
layout: list[zcm.ScaleLevel] | Sentinel = MISSING
582-
tile_matrix_set: tms.TileMatrixSet | Sentinel = MISSING
583-
tile_matrix_limits: dict[str, tms.TileMatrixLimit] | Sentinel = MISSING
580+
layout: list[zcm.ScaleLevel] | MISSING = MISSING # type: ignore[valid-type]
581+
tile_matrix_set: tms.TileMatrixSet | MISSING = MISSING # type: ignore[valid-type]
582+
tile_matrix_limits: dict[str, tms.TileMatrixLimit] | MISSING = MISSING # type: ignore[valid-type]
584583

585584
if "ogc_tms" in multiscales_flavor:
586585
# Create tile matrix set using geozarr function
587-
tile_matrix_set = create_native_crs_tile_matrix_set( # type: ignore[assignment]
586+
tile_matrix_set = create_native_crs_tile_matrix_set(
588587
native_crs,
589588
native_bounds,
590589
overview_levels,
591590
group_prefix=None,
592591
)
593592

594593
# Create tile matrix limits
595-
tile_matrix_limits = _create_tile_matrix_limits( # type: ignore[assignment]
594+
tile_matrix_limits = _create_tile_matrix_limits(
596595
overview_levels,
597596
tile_width=256,
598597
)
@@ -650,7 +649,7 @@ def add_multiscales_metadata_to_parent(
650649
geo_proj.CMO,
651650
),
652651
multiscales=MultiscaleMeta(
653-
layout=layout, # type: ignore[arg-type]
652+
layout=layout,
654653
resampling_method="average",
655654
tile_matrix_set=tile_matrix_set,
656655
tile_matrix_limits=tile_matrix_limits,

0 commit comments

Comments
 (0)