Files
docling-core/docling_core/utils/alias.py
Peter W. J. Staar 928aaed9ab chore: remove unnecesary copyright headers (#440)
* chore: remove unnecesary copyright headers

Signed-off-by: Peter Staar <taa@zurich.ibm.com>

* reformatted, still need to fix a test ...

Signed-off-by: Peter Staar <taa@zurich.ibm.com>

---------

Signed-off-by: Peter Staar <taa@zurich.ibm.com>
2025-11-27 11:17:23 +01:00

24 lines
805 B
Python

"""Define utility models and types related to field aliases."""
from pydantic import BaseModel, ConfigDict
class AliasModel(BaseModel):
"""Model for alias fields to ensure instantiation and serialization by alias."""
model_config = ConfigDict(populate_by_name=True)
def model_dump(self, **kwargs) -> dict:
"""Generate a dictionary representation of the model using field aliases."""
if "by_alias" not in kwargs:
kwargs = {**kwargs, "by_alias": True}
return super().model_dump(**kwargs)
def model_dump_json(self, **kwargs) -> str:
"""Generate a JSON representation of the model using field aliases."""
if "by_alias" not in kwargs:
kwargs = {**kwargs, "by_alias": True}
return super().model_dump_json(**kwargs)