Type Hinting for Structured Configs #1186
-
Hi! I'm wondering if there is an established way to type hint a function argument that is a DictConfig but further adheres to a particular structured config schema. Let me illustrate two possibilities -- simply annotating with
Is there a way to annotate the Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
So I think this issue is relevant -- looks like a generic
In the meantime, is there any way apart from just using the plain |
Beta Was this translation helpful? Give feedback.
-
The recommended practice is the second approach (duck typing). |
Beta Was this translation helpful? Give feedback.
The recommended practice is the second approach (duck typing).
If you really need the underlying object type to match, you can convert the OmegaConf config to object.
See OmegaConf.to_container and OmegaConf.to_object (which is a syntactic sugar using to_container).