def overwrite_by_env_vars(self, *args, **kwargs): # get the class cls = self.__class__ if args: # inace any args passed move them to kwargs # parse only the argument names cls_arg_names = [ arg[0] for arg in get_init_arguments_and_types(cls) ] # convert args to kwargs kwargs.update({k: v for k, v in zip(cls_arg_names, args)}) # update the kwargs by env variables # todo: maybe add a warning that some init args were overwritten by Env arguments kwargs.update(vars(parse_env_variables(cls))) # all args were already moved to kwargs return fn(self, **kwargs)
def match_env_arguments(cls) -> Namespace: return argparse_utils.parse_env_variables(cls)