{"id":17787917,"url":"https://github.com/zmievsa/pydantic-duality","last_synced_at":"2025-03-16T08:32:22.151Z","repository":{"id":86518763,"uuid":"605339520","full_name":"zmievsa/pydantic-duality","owner":"zmievsa","description":"Automatically and lazily generate three versions of your pydantic models: one with Extra.forbid, one with Extra.ignore, and one with all fields optional","archived":false,"fork":false,"pushed_at":"2024-04-01T09:12:05.000Z","size":907,"stargazers_count":31,"open_issues_count":8,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-25T23:11:53.730Z","etag":null,"topics":["hints","json-schema","pydantic","pydantic-models","python","python310","python311","schemas","validation"],"latest_commit_sha":null,"homepage":"https://ovsyanka83.github.io/pydantic-duality/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zmievsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-23T00:21:16.000Z","updated_at":"2024-09-04T18:10:06.000Z","dependencies_parsed_at":"2024-10-25T23:09:52.133Z","dependency_job_id":null,"html_url":"https://github.com/zmievsa/pydantic-duality","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":"0.027027027027026973","last_synced_commit":"b328b645e8bf9a2067a557a58d51a702caae7956"},"previous_names":["zmievsa/pydantic-duality","ovsyanka83/pydantic-duality"],"tags_count":0,"template":false,"template_full_name":"zmievsa/python-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmievsa%2Fpydantic-duality","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmievsa%2Fpydantic-duality/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmievsa%2Fpydantic-duality/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zmievsa%2Fpydantic-duality/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zmievsa","download_url":"https://codeload.github.com/zmievsa/pydantic-duality/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806070,"owners_count":20350775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hints","json-schema","pydantic","pydantic-models","python","python310","python311","schemas","validation"],"created_at":"2024-10-27T10:13:19.606Z","updated_at":"2025-03-16T08:32:21.654Z","avatar_url":"https://github.com/zmievsa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://zmievsa.github.io/pydantic-duality/\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/zmievsa/pydantic-duality/main/docs/_media/logo_with_text.svg\" alt=\"Pydantic Duality\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eAutomatically and lazily generate three versions of your pydantic models: one with Extra.forbid, one with Extra.ignore, and one with all fields optional\u003c/b\u003e\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/zmievsa/pydantic-duality/actions?query=workflow%3ATests+event%3Apush+branch%3Amain\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://github.com/zmievsa/pydantic-duality/actions/workflows/test.yaml/badge.svg?branch=main\u0026event=push\" alt=\"Test\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/zmievsa/pydantic-duality\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/zmievsa/pydantic-duality?color=%2334D058\" alt=\"Coverage\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/pydantic-duality/\" target=\"_blank\"\u003e\n    \u003cimg alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/pydantic-duality?color=%2334D058\u0026label=pypi%20package\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/pydantic-duality/\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/pydantic-duality?color=%2334D058\" alt=\"Supported Python versions\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n## Installation\n\n```bash\npip install pydantic-duality\n```\n\n## Quickstart\n\nGiven the following models:\n\n```python\n\nfrom pydantic_duality import DualBaseModel\n\n\nclass User(DualBaseModel):\n    id: UUID\n    name: str\n\nclass Auth(DualBaseModel):\n    some_field: str\n    user: User\n```\n\nUsing pydantic-duality is roughly equivalent to making all of the following models by hand:\n\n```python\n\nfrom pydantic import BaseModel\n\n# Equivalent to User and User.__request__\nclass UserRequest(BaseModel, extra=Extra.forbid):\n    id: UUID\n    name: str\n\n# Rougly equivalent to Auth and Auth.__request__\nclass AuthRequest(BaseModel, extra=Extra.forbid):\n    some_field: str\n    user: UserRequest\n\n\n# Rougly equivalent to User.__response__\nclass UserResponse(BaseModel, extra=Extra.ignore):\n    id: UUID\n    name: str\n\n# Rougly equivalent to Auth.__response__\nclass AuthResponse(BaseModel, extra=Extra.ignore):\n    some_field: str\n    user: UserResponse\n\n\n# Rougly equivalent to User.__patch_request__\nclass UserPatchRequest(BaseModel, extra=Extra.forbid):\n    id: UUID | None\n    name: str | None\n\n# Rougly equivalent to Auth.__patch_request__\nclass AuthPatchRequest(BaseModel, extra=Extra.forbid):\n    some_field: str | None\n    user: UserPatchRequest | None\n\n```\n\nSo it takes you up to 3 times less code to write the same thing. Note also that pydantic-duality does everything lazily so you will not notice any significant performance or memory usage difference when using it instead of writing everything by hand. Think of it as using all the customized models as cached properties.\n\nInheritance, inner models, custom configs, [custom names](https://zmievsa.github.io/pydantic-duality/#/?id=customizing-schema-names), config kwargs, isinstance and subclass checks work intuitively and in the same manner as they would work if you were not using pydantic-duality.\n\n## Help\n\nSee [documentation](https://zmievsa.github.io/pydantic-duality/#/) for more details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmievsa%2Fpydantic-duality","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzmievsa%2Fpydantic-duality","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzmievsa%2Fpydantic-duality/lists"}