Coverage for smartmdao / utils.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-02 20:01 +0200

1import inspect 

2from dataclasses import is_dataclass 

3from typing import List 

4from .models import Step 

5 

6def resolve_output_names(step: Step) -> List[str]: 

7 """ 

8 Determines the variable names a step produces. 

9 It checks manual_outputs first, then type hints, then defaults to function name. 

10 """ 

11 if step.manual_outputs: 

12 return step.manual_outputs 

13 

14 sig = inspect.signature(step.fn) 

15 ann = sig.return_annotation 

16 

17 # If the return type is a Dataclass, use its field names 

18 if isinstance(ann, type) and is_dataclass(ann): 

19 return list(ann.__dataclass_fields__.keys()) 

20 

21 # Default to the function name 

22 return [step.name]