Skip to content

Commit bcd4ff2

Browse files
authored
stubtest: hint when args in stub need to be keyword-only (#16210)
1 parent 99ba048 commit bcd4ff2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mypy/stubtest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,10 @@ def _verify_signature(
890890
# If the variable is in runtime.kwonly, it's just mislabelled as not a
891891
# keyword-only argument
892892
if stub_arg.variable.name not in runtime.kwonly:
893-
yield f'runtime does not have argument "{stub_arg.variable.name}"'
893+
msg = f'runtime does not have argument "{stub_arg.variable.name}"'
894+
if runtime.varkw is not None:
895+
msg += ". Maybe you forgot to make it keyword-only in the stub?"
896+
yield msg
894897
else:
895898
yield f'stub argument "{stub_arg.variable.name}" is not keyword-only'
896899
if stub.varpos is not None:

0 commit comments

Comments
 (0)