You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
P=ParamSpec('P')
R=TypeVar('R')
def__mutmut_dispatcher(func: Callable[P, R]) ->Callable[P, R]:
@wraps(func)deftrampoline(*args: P.args, **kwargs: P.kwargs) ->R:
# check environment variable# and call correct function from the mutants dictfunc_to_call=mutants_dict[...]
returnfunc_to_call(*args, **kwargs)
returntrampoline@__mutmut_dispatcherdefcheck(some_flag: bool=False) ->None:
returnsome_flag
And depending on the os.environ['MUTANT_UNDER_TEST'] the @__mutmut_dispatcher would pass the args to the original function or the mutated method. The decorator could use *args, **kwargs as parameters and thus accept any args (with or without defaults).
I also like that with the decorator we would not need to do parsing of the args and handle all edge cases ourselve, but simply pass on *args, **kwargs.
For static typing, I think using ParamSpec should retain the original signature for static typing.
But I'm not sure how it works with runtime type hints. Maybe with a @functool.wraps decorator this is fine?
Activity