Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
fix pydantic recursion error on JSON type
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Apr 18, 2024
1 parent 8c62744 commit 5de6693
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions stac_model/output.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Annotated, Any, List, Optional, Set, Union, cast
from typing import Annotated, Any, Dict, List, Optional, Set, Union, cast

from pydantic import AliasChoices, ConfigDict, Field, model_serializer
from pystac.extensions.classification import Classification

from stac_model.base import JSON, DataType, MLMBaseModel, ModelTask, OmitIfNone, ProcessingExpression
from stac_model.base import DataType, MLMBaseModel, ModelTask, OmitIfNone, ProcessingExpression


class ModelResult(MLMBaseModel):
Expand Down Expand Up @@ -32,7 +32,7 @@ class ModelResult(MLMBaseModel):

class MLMClassification(MLMBaseModel, Classification):
@model_serializer()
def model_dump(self, *_: Any, **__: Any) -> JSON: # type: ignore[override]
def model_dump(self, *_: Any, **__: Any) -> Dict[str, Any]:
return self.to_dict() # type: ignore[call-arg]

def __init__(
Expand Down Expand Up @@ -61,7 +61,10 @@ def __setattr__(self, key: str, value: Any) -> None:
else:
MLMBaseModel.__setattr__(self, key, value)

model_config = ConfigDict(arbitrary_types_allowed=True)
model_config = ConfigDict(
populate_by_name=True,
arbitrary_types_allowed=True,
)


# class ClassObject(BaseModel):
Expand Down

0 comments on commit 5de6693

Please sign in to comment.