Skip to content

Commit 735e2cb

Browse files
justinchubyCopilot
andcommitted
fix(tasks): add keys() and __contains__ to ComponentSpec
The test TestTTSTaskSpeakerEncoderOptional.test_build_with_speaker_encoder_attribute called task.components.keys() which failed because ComponentSpec only exposed .items() but not .keys(). Add keys() (returns output model names) and __contains__ (enables 'x' in spec) to give ComponentSpec a consistent dict-like inspection API alongside .items(). Co-authored-by: Copilot <[email protected]> Signed-off-by: Justin Chu <[email protected]>
1 parent da40c97 commit 735e2cb

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/mobius/tasks/_base.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ def items(self):
8989
"""Iterate over ``(output_name, attribute_name)`` pairs."""
9090
return self._components.items()
9191

92+
def keys(self):
93+
"""Return the output model names declared by this spec."""
94+
return self._components.keys()
95+
96+
def __contains__(self, item: str) -> bool:
97+
"""Return ``True`` if *item* is a declared output model name."""
98+
return item in self._components
99+
92100
def __repr__(self) -> str:
93101
parts = ", ".join(f"{k}={v!r}" for k, v in self._components.items())
94102
return f"ComponentSpec({parts})"

0 commit comments

Comments
 (0)