Skip to content

Commit ddbc0dd

Browse files
committed
[bug] Fix issue with source position yaml loading
1 parent 3f2f449 commit ddbc0dd

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

python_modules/dagster/dagster/_utils/yaml_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ def construct_object(self, node: Any, deep: Any = False) -> ValueAndSourcePositi
216216
Mapping[ValueAndSourcePositionTree, ValueAndSourcePositionTree], value
217217
).items():
218218
dict_with_raw_values[k.value] = v.value
219-
child_trees[k.value] = v.source_position_tree
219+
child_trees[k.value] = SourcePositionTree(
220+
position=k.source_position_tree.position,
221+
children=v.source_position_tree.children,
222+
)
220223
return ValueAndSourcePositionTree(
221224
dict_with_raw_values,
222225
SourcePositionTree(position=source_position, children=child_trees),

python_modules/dagster/dagster_tests/utils_tests/test_source_position.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ def visit(path: KeyPath, tree: SourcePositionTree):
4040
visit([], value_and_tree.source_position_tree)
4141
assert flattened == {
4242
"": "foo.yaml:2",
43-
"foo": "foo.yaml:3",
43+
"foo": "foo.yaml:2",
4444
"foo.bar": "foo.yaml:3",
4545
"foo.q": "foo.yaml:4",
4646
"foo.q.0": "foo.yaml:4",
4747
"foo.q.1": "foo.yaml:4",
4848
"foo.q.2": "foo.yaml:4",
49-
"foo.baz": "foo.yaml:6",
49+
"foo.baz": "foo.yaml:5",
5050
"foo.baz.0": "foo.yaml:6",
5151
"foo.baz.1": "foo.yaml:7",
5252
"foo.baz.1.b": "foo.yaml:7",
@@ -95,7 +95,7 @@ def __init__(self):
9595
populate_source_position_and_key_paths(value, parsed.source_position_tree)
9696
assert value.child.dicts[3][4]._source_position_and_key_path is not None # noqa: SLF001
9797
assert (
98-
str(value.child.dicts[3][4]._source_position_and_key_path.source_position) == "<string>:10" # noqa: SLF001
98+
str(value.child.dicts[3][4]._source_position_and_key_path.source_position) == "<string>:9" # noqa: SLF001
9999
)
100100
assert value.child.dicts[3][4]._source_position_and_key_path.key_path == [ # noqa: SLF001
101101
"child",

0 commit comments

Comments
 (0)