I have following setup:
@pytest.fixture
def check_answer() -> t.Callable[[dict[str, t.Any], dict[str, t.Any], int], None]:
def _check(
first_response: dict[str, t.Any],
second_response: dict[str, t.Any],
named_optional_arg: int = 1,
) -> None:
*assert stuff*
return _check
I then pass check_answer
as a parameter to test_my_answer
and I want to call it as check_answer(ans1, ans2, named_optional_arg=5)
. The optional argument is used very rarely, so it is important that the name is present when it is called, however, when I include the name, I get an error from mypy because of an unexpected keyword argument.
New contributor
duckasaur is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.