def test_lazy_attributes(): for attr in ["resolver", "translate", "typeclass_of", "algos"]: assert hasattr(mg, attr) with pytest.raises(TypeError, match="does not have a registered type"): mg.typeclass_of(set()) with pytest.raises(TypeError, match="does not have a registered type"): mg.type_of(set()) with pytest.raises(TypeError, match="does not have a registered type"): mg.translate(set(), "unknown type") assert isinstance(mg.resolver, Resolver) assert isinstance(mg.algos, Namespace)
def translate(self, dst_type: Union[str, ConcreteType, "Wrapper"], **props): import metagraph as mg # This uses the current default resolver return mg.translate(self, dst_type, **props)