{"id":46840,"library":"yamlable","title":"yamlable","description":"A thin wrapper around PyYAML that provides automatic serialization and deserialization of Python objects to/from YAML. Version 1.1.1 is current. Release cadence is low, with occasional maintenance updates.","status":"active","version":"1.1.1","language":"python","source_language":"en","source_url":"https://github.com/smarie/python-yamlable","tags":["yaml","serialization","deserialization","pyyaml"],"install":[{"cmd":"pip install yamlable","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for YAML parsing and emitting.","package":"PyYAML","optional":false}],"imports":[{"note":"The base class for making objects YAML-serializable.","symbol":"YamlAble","correct":"from yamlable import YamlAble"},{"note":"Decorator for marking class YAML tag info.","symbol":"yaml_info","correct":"from yamlable import yaml_info"}],"quickstart":{"code":"from yamlable import YamlAble, yaml_info\n\n@yaml_info(yaml_tag='!person')\nclass Person(YamlAble):\n    def __init__(self, name, age):\n        self.name = name\n        self.age = age\n\np = Person('Alice', 30)\nyaml_str = YamlAble.to_yaml(p)\nprint(yaml_str)\n# Output:\n# !person {age: 30, name: Alice}\n\nobj = YamlAble.from_yaml(yaml_str)\nassert isinstance(obj, Person)\nprint(obj.name)  # Alice","lang":"python","description":"Defines a YAML-serializable class with custom tag, then serializes and deserializes."},"warnings":[{"fix":"Use PyYAML's `yaml.dump` for plain dicts.","message":"yamlable only works with class instances (not dicts or primitives). For dicts, use PyYAML directly.","severity":"gotcha","affected_versions":"all"},{"fix":"Use unique tag names per class.","message":"The `yaml_tag` must be unique across all classes; duplicate tags cause ambiguous loading.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace `from yamlable import YamlObj` with `from yamlable import YamlAble` and rename usage.","message":"Version 1.0.0 changed the import base class from `YamlObj` to `YamlAble`. Old code using `YamlObj` breaks.","severity":"breaking","affected_versions":"<1.0.0"}],"env_vars":null,"search_vec":"'1.1.1':19 'around':5 'automat':9 'cadenc':23 'current':21 'deseri':12,32 'low':25 'mainten':28 'object':15 'occasion':27 'provid':8 'python':14 'pyyaml':6,33 'releas':22 'serial':10,31 'thin':3 'to/from':16 'updat':29 'version':18 'wrapper':4 'yaml':17,30 'yamlabl':1","created_at":"2026-06-07T13:01:53.043448+00:00","updated_at":"2026-06-07T13:01:53.043448+00:00","problems":[{"fix":"Inherit from YamlAble and decorate with @yaml_info(yaml_tag='!mytag').","cause":"The class does not inherit from YamlAble or lacks @yaml_info decorator.","error":"TypeError: Cannot dump type <class '__main__.MyClass'>"},{"fix":"Ensure the class with that @yaml_info tag is imported before calling `YamlAble.from_yaml`.","cause":"The tag is used in YAML but no corresponding class with that tag has been registered (or the class wasn't imported before loading).","error":"yaml.constructor.ConstructorError: could not determine a constructor for the tag '!mytag'"},{"fix":"Annotate your YAML with appropriate tags or use `yaml.load` with `Loader=yaml.SafeLoader` for non-tagged data.","cause":"Trying to use YamlAble.from_yaml on a plain YAML string that doesn't contain an object with the expected tag (e.g., a scalar or mapping without tag). It returns a dict/str instead of the expected class instance.","error":"AttributeError: 'str' object has no attribute 'name'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/smarie/python-yamlable","github":"https://github.com/smarie/python-yamlable","docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}