{"id":22999410,"url":"https://github.com/seapagan/pydantic-dynamic-models-test","last_synced_at":"2025-04-02T13:43:54.057Z","repository":{"id":264942282,"uuid":"860816025","full_name":"seapagan/pydantic-dynamic-models-test","owner":"seapagan","description":"This is some WIP/thoughts on how I can modify a Pydantic Model to return only a specified (dynamic) subset of fields.","archived":false,"fork":false,"pushed_at":"2024-09-21T08:58:47.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T00:55:16.506Z","etag":null,"topics":["dynamic-models","pydantic","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seapagan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-09-21T08:40:36.000Z","updated_at":"2024-09-21T08:58:50.000Z","dependencies_parsed_at":"2024-11-27T00:17:36.200Z","dependency_job_id":null,"html_url":"https://github.com/seapagan/pydantic-dynamic-models-test","commit_stats":null,"previous_names":["seapagan/pydantic-dynamic-models-test"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Fpydantic-dynamic-models-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Fpydantic-dynamic-models-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Fpydantic-dynamic-models-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seapagan%2Fpydantic-dynamic-models-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seapagan","download_url":"https://codeload.github.com/seapagan/pydantic-dynamic-models-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246826312,"owners_count":20840224,"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":["dynamic-models","pydantic","python"],"created_at":"2024-12-15T06:16:55.931Z","updated_at":"2025-04-02T13:43:54.025Z","avatar_url":"https://github.com/seapagan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Modifying Pydantic models\n\nThis is some WIP/thoughts on how I can modify a Pydantic Model to return only a\nspecified (dynamic) subset of fields.\n\nCurrently, `model_test4.py` is the closest to what I want to achieve.\n\nThis is work to improve my `sqliter` project, specifically the case where the\nuser wants to return only a subset of fields from a table, and will eventually\nreplace the code in the `model_validate_partial` class method in `model.py`.\n\nPutting it out here in the hope that someone else can benefit from it. There is\nnot a lot of info on how to do this, so I had to figure it out myself.\n\n## Usage\n\nYou need to have [uv](https://github.com/astral-sh/uv) installed to run the\ncode, then you can set up the virtual environment and install the dependencies:\n\n```bash\nuv sync\n```\n\nThen activate the virtual environment:\n\n```bash\nsource .venv/bin/activate\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e The only dependency is `pydantic`, so you can install it with `pip` if you\n\u003e don't want to use `uv`, or add this to your own project.\n\nThen you can run the individual example files:\n\n```bash\npython model_test4.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseapagan%2Fpydantic-dynamic-models-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseapagan%2Fpydantic-dynamic-models-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseapagan%2Fpydantic-dynamic-models-test/lists"}