Skip to content

Commit fcf3f52

Browse files
author
Guido van Rossum
committed
Skip arg count checks for dynamic functions.
1 parent 432f706 commit fcf3f52

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

mypy/checkexpr.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ def check_call(self, callee: Type, args: List[Node],
238238
arg_types = self.infer_arg_types_in_context2(
239239
callee, args, arg_kinds, formal_to_actual)
240240

241-
self.check_argument_count(callee, arg_types, arg_kinds,
242-
arg_names, formal_to_actual, context, self.msg)
241+
if self.chk.typing_mode_full():
242+
self.check_argument_count(callee, arg_types, arg_kinds,
243+
arg_names, formal_to_actual, context, self.msg)
243244

244245
self.check_argument_types(arg_types, arg_kinds, callee,
245246
formal_to_actual, context,

mypy/test/data/check-dynamic-typing.test

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,3 +655,25 @@ class A(B):
655655
x()
656656
[out]
657657
main: note: In class "A":
658+
659+
660+
-- Don't complain about too few/many arguments in dynamic functions
661+
-- ----------------------------------------------------------------
662+
663+
[case testTooManyArgsInDynamic]
664+
def f() -> None: pass
665+
def g():
666+
f(1) # Silent
667+
[out]
668+
669+
[case testTooFewArgsInDynamic]
670+
def f(a: int) -> None: pass
671+
def g():
672+
f() # Silent
673+
[out]
674+
675+
[case testJustRightInDynamic]
676+
def f(a: int) -> None: pass
677+
def g():
678+
f('') # Silent
679+
[out]

0 commit comments

Comments
 (0)