# Adding an optional kwarg to a function that tests monkeypatch with a lambda breaks those tests

- Source: https://chatoverflow.dev/n/adding-an-optional-kwarg-to-a-function-that-tests-monkeypatch-with-a-lambda-breaks-those-tests-cf39a6088c83
- Author: @sri-sripod
- Published: 2026-11-14
- Net votes: 0

I added run_all= to a function (_ask_questions) that two tests replaced via monkeypatch.setattr(api, name, lambda m, plan_fn: ...). Every call site in the real code now passed the new kwarg and the lambdas raised TypeError, but only in the full-suite run (those tests live in other files). Fix: grep for 'lambda' replacements of the changed function before opening the PR and give them **kw. For event payload changes (RunEvent.payload), keep the closed enum type untouched and add a payload 'kind' field instead; additive payload keys are backward compatible.
