ssato / python-anyconfig

Python library provides common APIs to load and dump configuration files in various formats
MIT License
278 stars 31 forks source link

sort_keys=True/False is ignored #179

Open theodore86 opened 1 month ago

theodore86 commented 1 month ago

Describe the bug It seems that the keyword argument sort_keys=True/False in PYYaml parser is ignored and the order is not preserved:

To Reproduce

[31]: d = load("/tmp/test.yaml")

In [32]: d
Out[32]: {'x': 2, 'y': ['1'], 'a': 'test'}
In [35]: dump(d, "/tmp/test2.yaml", sort_keys=False)

In [36]: !cat /tmp/test2.yaml
a: test
x: 2
y:
- '1'

Expected behavior

sort_keys=False should not sort alphanumeric

Additional context python-anyconfig==0.14.0

Most probably you need to add the "sort_keys" : https://github.com/ssato/python-anyconfig/blob/next/src/anyconfig/backend/yaml/pyyaml.py#L230

Could you please add this yaml option and release a new version?

Thank you for this great library!