Skip to content

Simplify model interface - #231

Closed
Kircheneer wants to merge 1 commit into
developfrom
simplify-model-interface
Closed

Simplify model interface#231
Kircheneer wants to merge 1 commit into
developfrom
simplify-model-interface

Conversation

@Kircheneer

Copy link
Copy Markdown
Contributor

This is a draft of an attempt to simplify the interface for defining models a bit. Here is what an example model definition now might look like:

fromtypingimportAnnotated, List. Optionalfromdiffsync.enumimportDiffSyncFieldtypefromdiffsyncimportDIffSyncModelclassCity(DiffSyncModel):
_modelname="city"name: Annotated[str, DiffSyncFieldType.IDENTIFIER]
population: Annotated[int, DiffSyncFieldType.ATTRIBUTE]
classCountry(DebugModel):
_modelname="country"name: Annotated[str, DiffSyncFieldType.IDENTIFIER]
iso_code: Annotated[Optional[str], DiffSyncFieldType.ATTRIBUTE]
cities: Annotated[List[City], DiffSyncFieldType.CHILDREN, "city"] = []

Open points

  • Evaluate, whether this breaking change (eyeing at 2.0) is worth it
  • Documentation
  • Think about further possibilites for simplification

@Kircheneer
Kircheneerforce-pushed the simplify-model-interface branch from ee108b6 to 52cd49bCompareJune 20, 2023 15:06
@KircheneerKircheneer mentioned this pull request Jun 20, 2023
7 tasks
@Kircheneer
Kircheneerforce-pushed the simplify-model-interface branch from 52cd49b to 723f88fCompareJune 20, 2023 15:20
@itdependsnetworks

Copy link
Copy Markdown
Contributor

I thought that this was only available in 3.9 and above? https://docs.python.org/3/library/typing.html#typing.Annotated

@Kircheneer

Copy link
Copy Markdown
ContributorAuthor

I thought that this was only available in 3.9 and above? https://docs.python.org/3/library/typing.html#typing.Annotated

True actually, I didn't know. Should use this for compatibility

@Kircheneer

Copy link
Copy Markdown
ContributorAuthor

Closing for now.

@jdrew82
jdrew82 deleted the simplify-model-interface branch March 27, 2025 22:36
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Kircheneer@itdependsnetworks