@@ -951,9 +951,9 @@ class PythonInputConfig:
951951 ] = field (default_factory = lambda : ["." ])
952952
953953 load_external_modules : Annotated [
954- bool ,
954+ bool | None ,
955955 Field (description = "Whether to always load external modules/packages." ),
956- ] = False
956+ ] = None
957957
958958 options : Annotated [
959959 PythonInputOptions ,
@@ -965,10 +965,31 @@ class PythonInputConfig:
965965 Field (description = "The locale to use when translating template strings." ),
966966 ] = None
967967
968+ @classmethod
969+ def coerce (cls , ** data : Any ) -> MutableMapping [str , Any ]:
970+ """Coerce data."""
971+ return data
972+
973+ @classmethod
974+ def from_data (cls , ** data : Any ) -> Self :
975+ """Create an instance from a dictionary."""
976+ return cls (** cls .coerce (** data ))
977+
968978
969979# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line.
970980@dataclass (** _dataclass_options ) # type: ignore[call-overload]
971981class PythonConfig (PythonInputConfig ): # type: ignore[override,unused-ignore]
972982 """Python handler configuration."""
973983
984+ inventories : list [Inventory ] = field (default_factory = list )
974985 options : dict [str , Any ] = field (default_factory = dict ) # type: ignore[assignment]
986+
987+ @classmethod
988+ def coerce (cls , ** data : Any ) -> MutableMapping [str , Any ]:
989+ """Coerce data."""
990+ if "inventories" in data :
991+ data ["inventories" ] = [
992+ Inventory (url = inv ) if isinstance (inv , str ) else Inventory (** inv )
993+ for inv in data ["inventories" ]
994+ ]
995+ return data
0 commit comments