AllenNeuralDynamics / Aind.Behavior.Services

https://allenneuraldynamics.github.io/Aind.Behavior.Services/
MIT License
0 stars 0 forks source link

Consider refactoring `RootModel` pattern for discriminated unions to use TypeAliasType #114

Open bruno-f-cruz opened 2 weeks ago

bruno-f-cruz commented 2 weeks ago

Following https://github.com/pydantic/pydantic/discussions/10635#discussioncomment-10970037

Seems like TypeAliasType would be a more friendly solution to solve this pattern. A quick tests shows that the only thing that is lost (which is not even being used at the moment) is the title of the root model on model construction.

Additionally, the TypeAliasType class does not seem to be importable from the typing module in 3.11 despite what is written in the OP, instead it must be imported from typing_extensions as of 3.11.