Skip to content

Commit

Permalink
test: add test showing whether properties are respected by @inputs_fr…
Browse files Browse the repository at this point in the history
…om_state
  • Loading branch information
hollandjg committed Aug 12, 2024
1 parent 8572b4a commit fc9c820
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/autora/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,27 @@ def inputs_from_state(f, input_mapping: Dict = {}):
Doing something on: U(conditions=[1, 2, 3, 4])
[3, 4, 5, 6]
If the state has a @property alias, this is respected:
>>> @inputs_from_state
... def function_which_needs_alias(alias):
... print("Doing something with: ", alias)
... new_conditions = [x + 2 for x in alias]
... return new_conditions
>>> @dataclass(frozen=True)
... class V(State):
... conditions: List = field(default_factory=list, metadata={"delta": "extend"})
...
... @property
... def alias(self):
... return self.conditions
>>> function_which_needs_alias(V(conditions=[1,2,3,4]))
Doing something with: [1, 2, 3, 4]
[3, 4, 5, 6]
"""
# Get the set of parameter names from function f's signature

Expand Down

0 comments on commit fc9c820

Please sign in to comment.