Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

remap #20

Open
Open
@PietroPasotti

Description

@PietroPasotti

add State.remap(Relation|Container) -> Relation|Container

role: given an object in the input state, get the corresponding one from the output state.
Goal: targeted comparison without the manual search

Right now if you want to check how a relation databag changes during event handling, you have to:

rel_in = Relation("foo")
state_in = State(relations=[rel_in, *<more relations>])
state_out = context.run(event, state_in)
rel_out = filter(lambda r: r.endpoint == rel_in.endpoint, state_out.relations)

That is, you're forced to manually search through all relations in order to find the corresponding one to the relation you've passed in the input state.
This is such a common use case that maybe having a uniform shortcut for 'give me the corresponding object in this state' could be a good API improvement.

This is low priority, syntactic sugar. First investigate how the users feel about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    big brainissue that requires some (complex) spec/design workenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions