Skip to content

Commit

Permalink
Mark frozen fields
Browse files Browse the repository at this point in the history
  • Loading branch information
cutoffthetop committed Feb 14, 2024
1 parent c2767d2 commit 68df38e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mex/common/identity/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from typing import Annotated

from pydantic import Field

from mex.common.models import BaseModel
from mex.common.types import Identifier, PrimarySourceID


class Identity(BaseModel):
"""Model for identifier lookup."""

identifier: Identifier
hadPrimarySource: PrimarySourceID
identifierInPrimarySource: str
stableTargetId: Identifier
identifier: Annotated[Identifier, Field(frozen=True)]
hadPrimarySource: Annotated[PrimarySourceID, Field(frozen=True)]
identifierInPrimarySource: Annotated[str, Field(frozen=True)]
stableTargetId: Annotated[Identifier, Field(frozen=True)]
1 change: 1 addition & 0 deletions mex/common/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ class MExModel(BaseModel):
"entity-type or whether this item was extracted, merged, etc. "
"identifiers will be assigned just once."
),
frozen=True,
),
]

Expand Down
2 changes: 2 additions & 0 deletions mex/common/models/extracted_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ExtractedData(MExModel):
"The primary source for MEx has itself as a primary source, which "
"is meant to be the only loop in the graph formed by MEx metadata."
),
frozen=True,
),
]
identifierInPrimarySource: Annotated[
Expand All @@ -63,6 +64,7 @@ class ExtractedData(MExModel):
),
examples=["123456", "item-501", "D7/x4/zz.final3"],
min_length=1,
frozen=True,
),
]

Expand Down

0 comments on commit 68df38e

Please sign in to comment.