Pydantic and singledispatch
I was reading about pydantic-singledispatch from Giddeon’s blog and found it very intersting. I’m getting ready to implement pydantic on my static site generator markata, and I think there are so uses for this idea, so I want to try it out. The Idea # Let’s set up some pydantic settings. We will need separate Models for each environment that we want to support for this to work. The whole idea is to use and type hints to provide unique execution for each environment. We might want something like a path_prefix in prod for environments like GithubPages that deploy to while keeping the root at in dev. Settings Model # Here is our model for our settings. We will create a CommonSettings model that will be used by all environments. We will also create a model that will be used in dev and that will be used in prod. We will use as the discriminator so pydantic knows which model to use. Singledispatch # Now let’s create our function. We will use to provide a unique execution for each environment…