Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify model interface #231

Closed
wants to merge 1 commit into from
Closed

Conversation

Kircheneer
Copy link
Collaborator

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:

from typing import Annotated, List. Optional

from diffsync.enum import DiffSyncFieldtype
from diffsync import DIffSyncModel


class City(DiffSyncModel):
    _modelname = "city"

    name: Annotated[str, DiffSyncFieldType.IDENTIFIER]
    population: Annotated[int, DiffSyncFieldType.ATTRIBUTE]


class Country(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 Kircheneer mentioned this pull request Jun 20, 2023
7 tasks
@itdependsnetworks
Copy link
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
Collaborator Author

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
Collaborator Author

Closing for now.

@Kircheneer Kircheneer closed this Feb 15, 2024
Sign up for free to 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