nebius/SWE-bench-extra huggingface dataset:
Repository: childsish/dynamic-yaml

Issue:
[Enhancement] - Method to resolve the dynamic object
Ran into the issue when trying to pass in a list to a pandas dataframe. I was trying to define some columns, but the list of columns wouldn't resolve. See below example:

```python
import dynamic_yaml
import pandas as pd

yml = '''
names:
  n1: "name1"
  n2: "name2"
columns:
  - "{names.n1}"
  - "{names.n2}"
'''


if __name__ == '__main__':
    config = dynamic_yaml.load(yml)

    df = pd.DataFrame(columns=config.columns)

    print(df.columns)
```
Yeilds:
```
Index(['{names.n1}', '{names.n2}'], dtype='object')
```

So either after a fix that resolves the object when passed, or a method I can call on the object such as `config.columns.as_list()` or `config.columns.as_set()` or `config.columns.resolve()`. Not sure what the best approach is.

Current approach is to unpack and store in a variable. Roughly the following:
```python
cols = [config.columns[x] for x in range(len(config.columns))]
```

Comments:

Patch:
diff --git a/dynamic_yaml/yaml_wrappers.py b/dynamic_yaml/yaml_wrappers.py
index 14c5ecc..1a08d27 100644
--- a/dynamic_yaml/yaml_wrappers.py
+++ b/dynamic_yaml/yaml_wrappers.py
@@ -78,6 +78,10 @@ class YamlList(DynamicYamlObject, MutableSequence):
         super().__setattr__('_collection', list(*args, **kwargs))
         super().__setattr__('_root', YamlDict([(YamlList.ROOT_NAME, self)]))
 
+    def __iter__(self):
+        for i in range(len(self)):
+            yield self[i]
+
     def insert(self, index: int, object):
         super().__getattribute__('_collection').insert(index, object)
 


Test patch:
diff --git a/tests/test_dynamic_yaml.py b/tests/test_dynamic_yaml.py
index c666952..3cd4bee 100644
--- a/tests/test_dynamic_yaml.py
+++ b/tests/test_dynamic_yaml.py
@@ -197,6 +197,34 @@ class TestDynamicYaml(TestCase):
         res = load(config, recursive=True)
         inner_test(**res)
 
+    def test_list_iteration(self):
+        config = '''
+        targets:
+          v1: value1
+          v2: value2
+        query:
+          - '{targets.v1}'
+          - '{targets.v2}'
+        '''
+
+        res = load(config)
+        self.assertEqual(['value1', 'value2'], list(res.query))
+
+    def test_dict_iteration(self):
+        config = '''
+        targets:
+          v1: value1
+          v2: value2
+        query:
+          v1: '{targets.v1}'
+          v2: '{targets.v2}'
+        '''
+
+        res = load(config)
+        self.assertEqual(['v1', 'v2'], list(res.query))
+        self.assertEqual(['value1', 'value2'], list(res.query.values()))
+        self.assertEqual([('v1', 'value1'), ('v2', 'value2')], list(res.query.items()))
+
 
 if __name__ == '__main__':
     import sys
Repository: childsish/dynamic-yaml

Issue:
How to preserve order when dumping?
How to preserve order when dumping?

Comments:

Patch:
diff --git a/dynamic_yaml/__init__.py b/dynamic_yaml/__init__.py
index 2ebbab4..5245f7e 100644
--- a/dynamic_yaml/__init__.py
+++ b/dynamic_yaml/__init__.py
@@ -37,8 +37,8 @@ def load(stream, loader=DynamicYamlLoader, recursive=False):
     return result
 
 
-def dump(data, *args, **kwargs):
-    return yaml.dump(data, *args, **kwargs)
+def dump(data, sort_keys=False, *args, **kwargs):
+    return yaml.dump(data, sort_keys=sort_keys, *args, **kwargs)
 
 
 add_wrappers(DynamicYamlLoader)


Test patch:
diff --git a/tests/test_representations.py b/tests/test_representations.py
index f2a3599..f8adacb 100644
--- a/tests/test_representations.py
+++ b/tests/test_representations.py
@@ -34,6 +34,34 @@ parameters: {tool1: {phase1: {subparameters: [0.5, 0.6]}, phase2: {subparameters
 project_name: hello-world'''),
             yaml.safe_load(dump(res)))
 
+    def test_insert_order_keys(self):
+        config = '''
+        one: 1
+        two: 2
+        three: 3
+        four: 4
+        five: 5
+        '''
+
+        self.assertEqual(
+            dump(load(config)),
+            'one: 1\ntwo: 2\nthree: 3\nfour: 4\nfive: 5\n'
+        )
+
+    def test_sorted_keys(self):
+        config = '''
+        one: 1
+        two: 2
+        three: 3
+        four: 4
+        five: 5
+        '''
+
+        self.assertEqual(
+            dump(load(config), sort_keys=True),
+            'five: 5\nfour: 4\none: 1\nthree: 3\ntwo: 2\n'
+        )
+
 
 if __name__ == '__main__':
     import sys