Posts tagged: python

All posts with the tag "python"

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.

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 functools.singledispatch 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 /<name-of-repo> while keeping the root at / in dev.

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 DevSettings model that will be used in dev and ProdSettings that will be used in prod. We will use env as the discriminator so pydantic knows which model to use.

...

2 min read

I really like having global cli command installed with pipx. Since textual (the css release) is out I want to be able...

I am working through the textual tutorial, and I want to put it in a proper cli that I can pip install and run the co...

hugo puts it in the base url https://gohugo.io/getting-started/configuration/#baseurl * mkdocs uses a special cli bui...

I have no experience in django, and in my exploration to become a better python developer I am dipping my toe into on...