{"id":7511,"library":"poyo","title":"Poyo, a Lightweight YAML Parser","description":"Poyo is a lightweight YAML parser for Python (current version 0.5.0). It focuses on parsing a chosen subset of the YAML format, primarily designed for configuration files like those used by cookiecutter. It explicitly does not support deserialization of arbitrary Python objects, YAML serialization, or JSON compatibility. The project is in maintenance mode with infrequent updates, with the last release in July 2019, but it remains functional for its intended scope.","status":"active","version":"0.5.0","language":"en","source_language":"en","source_url":"https://github.com/hackebrot/poyo","tags":["yaml","parser","configuration","lightweight"],"install":[{"cmd":"pip install poyo","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Runtime environment","package":"python","version":">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"}],"imports":[{"note":"Main function to parse a YAML string into a Python dictionary.","symbol":"parse_string","correct":"from poyo import parse_string"},{"note":"Custom exception raised for parsing errors.","symbol":"PoyoException","correct":"from poyo import PoyoException"}],"quickstart":{"code":"from poyo import parse_string, PoyoException\n\nyaml_string = \"\"\"\ndefault_context:\n    greeting: Hello\n    is_enabled: true\n    count: 123\n    items:\n        - apple\n        - banana\n        - null\nlong_description: >\n    This is a multiline string.\n    It demonstrates how to handle\n    text blocks introduced in 0.5.0.\n\"\"\"\n\ntry:\n    config = parse_string(yaml_string)\n    print(config)\n    # Expected output similar to:\n    # {\n    #     'default_context': {\n    #         'greeting': 'Hello',\n    #         'is_enabled': True,\n    #         'count': 123,\n    #         'items': ['apple', 'banana', None]\n    #     },\n    #     'long_description': 'This is a multiline string. It demonstrates how to handle text blocks introduced in 0.5.0.'\n    # }\nexcept PoyoException as e:\n    print(f\"Error parsing YAML: {e}\")","lang":"python","description":"Parses a simple YAML string using `parse_string` and demonstrates basic type conversion and multiline string handling, with error handling for parsing issues."},"warnings":[{"fix":"Ensure your YAML adheres to the basic structure supported by Poyo (scalars, lists, dictionaries). For full YAML specification support, consider libraries like PyYAML.","message":"Poyo only supports a *subset* of the YAML specification. It does not support arbitrary Python object deserialization, YAML serialization, or compatibility with JSON. Attempting to use advanced YAML features (e.g., anchors, tags, complex mappings) will likely result in parsing errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `poyo>=0.3.0` to ensure `~` is correctly parsed as `None`.","message":"The `~` character (YAML's representation for null) was not correctly recognized as `None` in Python before version 0.3.0, leading to unexpected string values.","severity":"gotcha","affected_versions":"<0.3.0"},{"fix":"Upgrade to `poyo>=0.4.2` to resolve issues with lists containing comments and blank lines.","message":"Earlier versions had bugs with parsing list items that included comments or blank lines, leading to incorrect or incomplete data structures.","severity":"gotcha","affected_versions":"<0.4.2"},{"fix":"Upgrade to `poyo>=0.5.0` to use multiline string features. For older versions, represent long strings as single-line quoted strings.","message":"Multiline strings using the `>` or `|` block scalar indicators are only supported in version 0.5.0 and later.","severity":"gotcha","affected_versions":"<0.5.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Review the YAML content and simplify it to basic key-value pairs, lists, and scalars. If advanced YAML features are required, switch to a full-featured YAML parser like `PyYAML`.","cause":"Attempting to parse YAML that uses features outside of Poyo's supported subset (e.g., YAML tags, anchors/aliases, or malformed syntax).","error":"poyo.PoyoException: Error parsing YAML: Line ... Column ...: Expected a mapping or sequence start"},{"fix":"This often occurs in older versions of poyo. Ensure you are using `poyo>=0.3.0` to correctly handle `null` values. Also, verify that your YAML structure matches the expected Python dictionary access path.","cause":"A YAML `null` value (represented by `~` or `null`) was not parsed as Python's `None`, but as a string, or a key was expected but not found due to a parsing error in older versions.","error":"KeyError: 'some_key' or AttributeError: 'NoneType' object has no attribute 'get'"},{"fix":"Check for correct YAML indentation and ensure all strings with special characters or spaces are properly quoted. Consider upgrading to the latest Poyo version (`0.5.0`) as several parsing bugs were fixed in later releases.","cause":"This error can occur when Poyo encounters unexpected characters or structures, such as unquoted strings containing special characters or improper indentation, especially in older versions when list/comment handling was less robust.","error":"Error parsing YAML: Line ... Column ...: Could not parse scalar"}]}