cdgriffith / cdgriffith/Box

to_yaml() does not honor ordered_box

Open
#104 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
2.8k
Forks
135
PR merge metrics
No merged PRs in 30d

Description

```python
In [1]: from box import Box
In [2]: ordered_box = Box(ordered_box=True)
In [3]: ordered_box.zlast = 'first'
In [4]: ordered_box.afirst = 'last'
In [5]: ordered_box.keys()
Out[5]: ['zlast', 'afirst'] # correct, as expected
In [6]: ordered_box.to_yaml()
Out[6]: 'afirst: last\nzlast: first\n' # not ordered as expected!
```

YAML really looks better when ordered logically, not arbitrarily!

Contributor guide

Open the contributing guide

Research direction

Start at the Box.to_yaml() entry point and reproduce the ordered_box example from the issue. Check how the mapping is passed to YAML serialization, then verify that the generated YAML preserves insertion order, including the zlast and afirst example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.