Skip to content

generator

dandy.intel.generator

IntelClassGenerator

from_callable_signature classmethod

Source code in dandy/intel/generator.py
@classmethod
def from_callable_signature(
        cls,
        callable_: Callable
) -> Type[BaseIntel]:
    signature = inspect.signature(callable_)

    typed_kwarg_dict = {}

    for name, param in signature.parameters.items():
        if param.annotation is inspect._empty:
            raise IntelCriticalException(f'Parameter {name} of {callable_} has no annotation')

        typed_kwarg_dict[name] = (param.annotation, ...)

    return cls.from_typed_kwargs(
        f'{callable_.__name__}Intel',
        TypedKwargs(typed_kwarg_dict)
    )

from_typed_kwargs staticmethod

Source code in dandy/intel/generator.py
@staticmethod
def from_typed_kwargs(
        intel_class_name: str,
        typed_kwargs: TypedKwargs
) -> Type[BaseIntel]:
    return create_model(
        intel_class_name,
        __base__=BaseIntel,
        **typed_kwargs
    )