Skip to content

Commit

Permalink
Fix bug that occurs with dataclass_json 0.62 (#493)
Browse files Browse the repository at this point in the history
* remove "undefined" catch-all flag from a field

* mypy fixes
  • Loading branch information
zigaLuksic authored Nov 13, 2023
1 parent fb56c6f commit 6f8cbb4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sentinelhub/api/byoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ByocCollectionAdditionalData:
other_data: CatchAll = field(default_factory=dict)


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.INCLUDE)
@dataclass_json(letter_case=LetterCase.CAMEL)
@dataclass
class ByocCollection(BaseCollection):
"""Dataclass to hold BYOC collection data"""
Expand Down
4 changes: 2 additions & 2 deletions sentinelhub/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
letter_case=LetterCase.CAMEL,
)

geometry_config = dataclass_config( # type: ignore[misc]
geometry_config = dataclass_config(
encoder=Geometry.get_geojson,
decoder=lambda geojson: Geometry.from_geojson(geojson) if geojson else None,
exclude=lambda geojson: geojson is None,
Expand All @@ -31,7 +31,7 @@

def enum_config(enum_class: Type[Enum]) -> Dict[str, dict]:
"""Given an Enum class it provide an object for serialization/deserialization"""
return dataclass_config( # type: ignore[misc]
return dataclass_config(
encoder=lambda enum_item: enum_item.value,
decoder=lambda item: enum_class(item) if item else None,
exclude=lambda item: item is None,
Expand Down
6 changes: 3 additions & 3 deletions sentinelhub/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import warnings
from abc import ABCMeta, abstractmethod
from math import ceil
from typing import Callable, Dict, Iterator, Tuple, TypeVar, Union, cast
from typing import Callable, Dict, Iterator, Tuple, TypeVar, Union

import shapely.geometry
import shapely.geometry.base
Expand Down Expand Up @@ -159,9 +159,9 @@ def _tuple_from_list_or_tuple(
:raises: TypeError
"""
if len(bbox) == 4:
min_x, min_y, max_x, max_y = cast(Tuple[float, float, float, float], bbox)
min_x, min_y, max_x, max_y = bbox
else:
(min_x, min_y), (max_x, max_y) = cast(Tuple[Tuple[float, float], Tuple[float, float]], bbox)
(min_x, min_y), (max_x, max_y) = bbox
return float(min_x), float(min_y), float(max_x), float(max_y)

@staticmethod
Expand Down

0 comments on commit 6f8cbb4

Please sign in to comment.