def get_item_type()

in packages/autorest.python/autorest/m4reformatter/__init__.py [0:0]


def get_item_type(yaml_data: Dict[str, Any], item_name: str, enable_exception: bool = True) -> Optional[Dict[str, Any]]:
    try:
        return next(p["type"] for p in yaml_data.get("properties", []) if p["wireName"] == item_name)
    except StopIteration:
        pass
    for parent in yaml_data.get("parents", []):
        result = get_item_type(parent, item_name, False)
        if result:
            return result
    if enable_exception:
        raise StopIteration(f"Could not find item type {item_name} from type {yaml_data['name']}")
    return None