Open kurtbrose opened 3 years ago
one approach forward would be to add a param to _glom()
def _glom(target, spec, scope, target_move=_MISSING):
if target_move is not _MISSING:
scope[Path] = target_move
or similar -- storing something in the scope that says "here is how the current target was derived from the previous target"
possibly something that also requires looking at the spec to interpret
there was some prototyping of
scope[Path]
as a mechanism for tracking target path, but there are some flaws and also it eats a lot of performance for light specs (e.g. list-of-dicts)here are some of the issues:
e.g. a very simple case:
While evaluating the first
T
, the list-scope will have path=0; the T-scope will have no pathWhen evaluating the second
T
, the list-scope will have path=1; the T-scope will have no pathThis really becomes a problem when something like branching gets introduced -- if you want to be able to "rewind" and generate a nice clean error message involving the target-path for why a previous branch failed it is impossible because that information got overwritten in the parent scope