If you take this for example
import inspect
import sys
def all_kwargs(func):
locals = sys._getframe().f_back.f_locals
d = {
name: locals[name]
for name, param in inspect.signature(func).parameters.items()
if (
param.kind is inspect.Parameter.KEYWORD_ONLY
or param.kind is inspect.Parameter.VAR_KEYWORD
)
}
d.update(d["kwargs"])
del d["kwargs"]
return d
some_list_of_names = ["b", "c"]
def foo(*, a, b, **kwargs):
return [all_kwargs(foo)[name] for name in some_list_of_names]
foo(a=2, b=3, c=4)
It can easily be avoided and would make more sense outside of the list comp, but the error is not exactly clear




I count 8 (ignoring brackets)
