≈ the.bay.news

How Do I Avoid/Override the dict[str, Any] Type When Loading From TOML?

Discussions on Python.org
How Do I Avoid/Override the dict[str, Any] Type When Loading From TOML?
I’m writing a Python package that I have tried to type-hint throughout, but I keep running into typing mismatches because the result of tomllib.load(config) is typed as dict[str, Any]. I understand why tomllib would do this, but I don’t understand how to prevent the resulting mismatch with my fully typed Config class. I’ve tried loading the data into a fully typed ConfigLoader class that subclasses typing.TypedDict first, then passing that to my actual Config class, but that does not help. Su...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.