Title: Inherit from pydantic BaseModel (if possible) · Issue #1151 · larray-project/larray · GitHub
Open Graph Title: Inherit from pydantic BaseModel (if possible) · Issue #1151 · larray-project/larray
X Title: Inherit from pydantic BaseModel (if possible) · Issue #1151 · larray-project/larray
Description: We currently use a lot of pydantic internal API, which is bound to bite us at some point. This issue is about exploring pydantic v2 new features to see whether it is possible to avoid all those internal API use and simply inherit from Ba...
Open Graph Description: We currently use a lot of pydantic internal API, which is bound to bite us at some point. This issue is about exploring pydantic v2 new features to see whether it is possible to avoid all those int...
X Description: We currently use a lot of pydantic internal API, which is bound to bite us at some point. This issue is about exploring pydantic v2 new features to see whether it is possible to avoid all those int...
Opengraph URL: https://github.com/larray-project/larray/issues/1151
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inherit from pydantic BaseModel (if possible)","articleBody":"We currently use a lot of pydantic internal API, which is bound to bite us at some point. This issue is about exploring pydantic v2 new features to see whether it is possible to avoid all those internal API use and simply inherit from BaseModel instead. See discussion from PR #1144 below:\n\n---\nI do not remember why I implemented a simplified version of the `ModelMetaclass`. I **think** it was to allow *unloaded* members after the initialization of the checked session (when reading from a file). I was also to allow the declaration of members without a default value in CheckedParameters (defined using the `frozen` flag of pydantic.\n\nIn the `__init__` method of the `CheckedSession` class, we have:\n```python\n for name, field in self.__pydantic_fields__.items():\n value = input_data.pop(name, NotLoaded())\n\n if isinstance(value, NotLoaded):\n if field.default is PydanticUndefined:\n warnings.warn(f\"No value passed for the declared variable '{name}'\", stacklevel=2)\n self.__setattr__(name, value, skip_frozen=True, skip_validation=True)\n else:\n self.__setattr__(name, field.default, skip_frozen=True)\n else:\n self.__setattr__(name, value, skip_frozen=True)\n\n # --- undeclared variables\n for name, value in input_data.items():\n self.__setattr__(name, value, skip_frozen=True, stacklevel=2)\n```\n\n**Maybe** the v2 version of pydantic has a special mechanism to write a sort of dedicated `__init__` method or to skip validation and set `frozen` to False during the initialization process only. So that we could make `CheckedSession` to inherit from pydantic `BaseModel`. But that requires more investigation in the pydantic documentation plus the time to make some proof of concept implementation. But I don't have time for the moment. But I can open an issue for that and come back to it later if you want.\n\n_Originally posted by @alixdamman in https://github.com/larray-project/larray/pull/1144#discussion_r2571770848_\n ","author":{"url":"https://github.com/gdementen","@type":"Person","name":"gdementen"},"datePublished":"2025-12-08T10:35:36Z","url":"https://github.com/larray-project/larray/issues/1151"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:502cab82-00c6-9b63-1178-6f2f48e35b2d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B734:2FF516:BF0512:1004238:6B004D01 |
| html-safe-nonce | 7ba7eea6b6a4dcee152b873746afc5bf1069b7d56746cb90eaaf154bb989684b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzM0OjJGRjUxNjpCRjA1MTI6MTAwNDIzODo2QjAwNEQwMSIsInZpc2l0b3JfaWQiOiIzNDczMjMwNjk1NjEzMDkxMDc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 39f750b37180213ed3b7de23d69b16aa314534b662100d45a064057a89ddad61 |
| hovercard-subject-tag | issue:3705739608 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/larray-project/larray/1151/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1246fdf27a25854329768dc9abe810b550f71c03f86cc2286c1ef1e131dbe17f/larray-project/larray/issues/1151 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1246fdf27a25854329768dc9abe810b550f71c03f86cc2286c1ef1e131dbe17f/larray-project/larray/issues/1151 |
| og:image:alt | We currently use a lot of pydantic internal API, which is bound to bite us at some point. This issue is about exploring pydantic v2 new features to see whether it is possible to avoid all those int... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gdementen |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| turbo-cache-control | no-preview |
| go-import | github.com/larray-project/larray git https://github.com/larray-project/larray.git |
| octolytics-dimension-user_id | 26460981 |
| octolytics-dimension-user_login | larray-project |
| octolytics-dimension-repository_id | 16981067 |
| octolytics-dimension-repository_nwo | larray-project/larray |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16981067 |
| octolytics-dimension-repository_network_root_nwo | larray-project/larray |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width