[docs]defwrap(_:Callable[P,Any])->Callable[[Callable[...,T]],Callable[P,T]]:"""Wrap a `Converter` `__init__` in a type-safe way."""defimpl(x:Callable[...,T])->Callable[P,T]:returnxreturnimpl
[docs]defis_primitive_enum(type:Any,include_bare_enums:bool=False)->bool:"""Is this a string or int enum that can be passed through?"""returnis_subclass(type,Enum)and(is_subclass(type,(str,int))or(include_bare_enumsandtype.mro()[1:]==Enum.mro()))
[docs]defliterals_with_enums_unstructure_factory(typ:Any,converter:Converter)->UnstructureHook:"""An unstructure hook factory for literals containing enums. If all contained enums can be passed through (their unstructure hook is `identity`), the entire literal can also be passed through. """ifall(converter.get_unstructure_hook(type(arg))==identityforarginget_args(typ)):returnidentityreturnconverter.unstructure