{"library":"saneyaml","title":"SaneYAML","description":"SaneYAML (version 0.6.1) is a lightweight wrapper around PyYAML designed to provide a safer and more predictable experience when reading and writing configuration files. It focuses on preserving dictionary order and preventing common PyYAML footguns such as unwanted implicit type conversions for strings like 'yes', 'no', dates, or numbers. Its release cadence is sporadic, focusing on stability and essential bug fixes.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install saneyaml"],"cli":null},"imports":["from saneyaml import load","from saneyaml import dump"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from saneyaml import load, dump\nimport io\n\n# Example YAML data\nconfig_data = {\n    'name': 'My App',\n    'version': '1.0.0',\n    'settings': {\n        'debug': 'No',  # saneyaml keeps this as string, not bool\n        'log_level': 'INFO',\n        'features': ['alpha', 'beta']\n    },\n    'last_updated': '2023-10-27' # saneyaml keeps this as string, not datetime\n}\n\n# Dump to a YAML string (preserving order and types)\noutput_stream = io.StringIO()\ndump(config_data, output_stream)\nyaml_string = output_stream.getvalue()\nprint(\"\\n--- Dumped YAML ---\\n\" + yaml_string)\n\n# Load from a YAML string (preventing implicit conversions)\nloaded_data = load(yaml_string)\n\nprint(\"\\n--- Loaded Data ---\")\nprint(f\"Debug setting type: {type(loaded_data['settings']['debug'])} (value: {loaded_data['settings']['debug']})\")\nprint(f\"Last updated type: {type(loaded_data['last_updated'])} (value: {loaded_data['last_updated']})\")\nprint(f\"Loaded data equality: {loaded_data == config_data}\")\n\n# Demonstrate order preservation (requires Python 3.7+ for dicts)\n# For older Pythons, saneyaml handles order internally.\noriginal_keys = list(config_data.keys())\nloaded_keys = list(loaded_data.keys())\nprint(f\"Original top-level keys order: {original_keys}\")\nprint(f\"Loaded top-level keys order: {loaded_keys}\")","lang":"python","description":"This quickstart demonstrates how to use `saneyaml.load` and `saneyaml.dump` to process YAML data. It highlights SaneYAML's core features: preserving order of keys and preventing implicit type conversions for values like 'yes', 'no', or date strings, which are often problematic in default PyYAML usage. Notice how 'No' and '2023-10-27' are loaded as strings, not booleans or datetime objects.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}