Skip to content

Commit cc2a07b

Browse files
committed
2 parents 92d68ed + cae6ffa commit cc2a07b

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎src/osw/core.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010
from copy import deepcopy
1111
from enum import Enum
12-
from typing import Any, Dict, List, Optional, Type, Union
12+
from typing import Any, Dict, List, Optional, Type, Union, overload
1313
from uuid import UUID, uuid4
1414
from warnings import warn
1515

@@ -729,6 +729,21 @@ class LoadEntityResult(BaseModel):
729729
entities: Union[model.Entity, List[model.Entity]]
730730
"""The dataclass instance(s)"""
731731

732+
# fmt: off
733+
@overload
734+
def load_entity(self, entity_title: str) -> model.Entity:
735+
...
736+
737+
@overload
738+
def load_entity(self, entity_title: List[str]) -> List[model.Entity]:
739+
...
740+
741+
@overload
742+
def load_entity(self, entity_title: LoadEntityParam) -> LoadEntityResult:
743+
...
744+
745+
# fmt: on
746+
732747
def load_entity(
733748
self, entity_title: Union[str, List[str], LoadEntityParam]
734749
) -> Union[model.Entity, List[model.Entity], LoadEntityResult]:

‎src/osw/model/static.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ class Config:
9292
# Additional fields are ignored
9393
validate_assignment = True
9494
# Ensures that the assignment of a value to a field is validated
95+
smart_union = True
96+
# To avoid unexpected coercing of types, the smart_union option is enabled
97+
# See: https://docs.pydantic.dev/1.10/usage/model_config/#smart-union
98+
# Not required in v2 as this will become the new default
9599

96100
def __init__(self, **data):
97101
if data.get("label"):

0 commit comments

Comments
 (0)