I needed this for a project, None of the solutions worked in my situation but this is what I ended up with
def get_kwarg_for_class(cls, kwargs): rval = {k: v for k, v in kwargs.items() if k in inspect.get_annotations(cls)} return rval