The issue is,that Class-level function attributes (including lambdas) become methods via Python’s descriptor protocol. python descriptor doc
Now, calling instance.boo() tries to pass the instance as the first argument—even if your code object has zero parameters. inspect.signature sees the mismatch (a code object with 0 parameters vs. a “bound method” expecting 1) and raises ValueError: invalid method signature. Adding at least one parameter (e.g., lambda self:) or decorating with @staticmethod aligns the function’s parameter list with how Python is actually calling it.
TLDR - A zero-argument function in a class is not a valid instance method signature, and inspect. signature flags it as invalid. Suppose you want a no-argument callable that doesn’t accept self. In that case, you must explicitly tell Python that it’s a staticmethod (or define it elsewhere) so that the automatic binding of self is disabled.