move check for func being None above functools.wrap