Closed mthuurne closed 1 year ago
I decided to add the support for Any
, as we were already cutting off part of the TOML data in production, to configure the Python logging system. Because that happened at the root of the tree and no re-insertion was needed, I didn't realize earlier that supporting Any
could simplify things.
Currently if you use
typing.Any
in an annotation, this will result in the messageAnnotation for field '<context>' is not a type
. While this is technically correct (Any
is not a subclass oftype
), it isn't very helpful to the end user.One solution would be to add a dedicated error message saying that
Any
is unsupported.Alternatively, we could support
Any
by accepting any data type that the TOML parser can produce. While this doesn't provide type safety, there might be situations where providing a full type hierarchy is not feasible or not worth the effort, for example when configuring plugins or optional modules. WithoutAny
support, the only solution would be to cut out specific fields from the parsed TOML data prior to calling thebind()
method and then re-inserting them after binding, which is messier than using anAny
annotation.