Skip to content

Add support of Python Pydantic #1474

Closed
Closed

Description

@Forden

It would be great to implement generating of Pydantic models.
It's like Python3.6, but without __init__ and with Field with alias definition.

from typing import Optional

from pydantic import BaseModel, Field


class Test(BaseModel):
    test_value: str = Field(..., alias='testValue')
    another_value: Optional[int] = Field(alias='another_value')


data = Test(**{'testValue': 'some data'})

print(data.test_value)
# > some data

other_data = Test(**{'testValue': 'more data', 'another_value': 123})

print(other_data.test_value)
# > more data
print(other_data.another_value)
# > 123

Activity

  1. changed the title [-]Adding Python Pydantic[/-] [+]Add support of Python Pydantic[/+] on May 16, 2020
  2. dvdsgl commented on May 31, 2020

    @dvdsgl
    Member

    Great idea! We would love this as a Python option. Closing, though, because we do not keep feature requests as open issues.

  3. RazCrimson commented on Jan 3, 2023

    @RazCrimson

    @dvdsgl

    Is there any work or progress on this?

    If not, will contributions for this be accepted?

  4. dvdsgl commented on Jan 5, 2023

    @dvdsgl
    Member

    @RazCrimson sure! If you make a PR with supporting test fixture that passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions