MCPcopy Index your code
hub / github.com/faust-streaming/faust / build_function

Function build_function

faust/utils/codegen.py:106–121  ·  view source on GitHub ↗

Generate function from Python from source code string.

(
    name: str,
    source: str,
    *,
    return_type: Any = MISSING,
    globals: Dict[str, Any] = None,
    locals: Dict[str, Any] = None,
)

Source from the content-addressed store, hash-verified

104
105
106def build_function(
107 name: str,
108 source: str,
109 *,
110 return_type: Any = MISSING,
111 globals: Dict[str, Any] = None,
112 locals: Dict[str, Any] = None,
113) -> Callable:
114 """Generate function from Python from source code string."""
115 assert locals is not None
116 if return_type is not MISSING:
117 locals["_return_type"] = return_type
118 exec(source, globals, locals) # nosec: B102
119 obj = locals[name]
120 obj.__sourcecode__ = source
121 return cast(Callable, obj)
122
123
124def build_function_source(

Callers 1

FunctionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected