in chz/blueprint/_blueprint.py [0:0]
def cast(self, value: str) -> object:
# If we have a field-level cast, always use that!
if self.blueprint_cast is not None:
return self.blueprint_cast(value)
# If we have a meta_factory, route casting through it. This allows user expectations
# of types that result from casting to better match their expectations from polymorphic
# construction (e.g. using default_cls from chz.factories.subclass)
if self.meta_factory is not None:
return self.meta_factory.perform_cast(value)
# TODO: maybe MetaFactory should have default impl and this should be:
# return chz.factories.MetaFactory().perform_cast(value, self.type)
return _simplistic_try_cast(value, self.type)