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

Fix bug that occurs with dataclass_json 0.62 #493

Merged
merged 2 commits into from
Nov 13, 2023
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 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)
Comment on lines 161 to 165
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to limit the various options how to define a bbox? it seems like a similar situation as in case of features in eolearn. But this is a separate issue, so this is just a comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already did quite a bit
the problem with that is that it is fairly code-breaking, so it's a sin of the past that we're slowly correcting


@staticmethod
Expand Down