runtime
337 / 500
question 337 Functional & Dynamic Python · medium

Check a plugin call before making it

A report runs plugin functions with keyword arguments taken from a settings file. Before running anything, it wants a list of problems. Write call_problems(func, kwargs): return a sorted list of "missing: <name>" for required parameters not in kwargs (positional-or-keyword or keyword-only, without a default) and "unexpected: <name>" for keys the function doesn't accept. A function with **kwargs accepts any key.

Functioncall_problems(func, kwargs)
Returnsa sorted list of problem texts; [] when the call would work
Toolsinspect.signature(func).parameters, each parameter's kind and default

Loading your progress…

Check a plugin call before making it — Python practice · Runtime