Skip to content

Commit e007c3b

Browse files
committed
Account for optional posonly args
1 parent 6e75bfd commit e007c3b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mypy/checkexpr.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ def check_argument_count(
23892389
)
23902390

23912391
# Check for too many or few values for formals.
2392-
missing_contiguous_pos_block = []
2392+
missing_contiguous_pos_block: list[int] = []
23932393
seen_kw = False
23942394
for i, kind in enumerate(callee.arg_kinds):
23952395
mapped_args = formal_to_actual[i]
@@ -2445,8 +2445,12 @@ def check_argument_count(
24452445
# missing from the call but doesn't belong to continuous positional prefix,
24462446
# it was already reported as a missing kwarg. All args before first prefix
24472447
# item are guaranteed to have been passed positionally.
2448-
passed_or_reported_names = callee.arg_names[missing_contiguous_pos_block[-1] + 1 :]
2449-
assert None not in passed_or_reported_names
2448+
passed_or_reported_names = [
2449+
name
2450+
for name in callee.arg_names[missing_contiguous_pos_block[-1] + 1 :]
2451+
# None may be there if it was an optional posonly param
2452+
if name is not None
2453+
]
24502454
names_to_use = [None] * missing_contiguous_pos_block[0] + passed_or_reported_names
24512455
self.msg.too_few_arguments(callee, context, names_to_use)
24522456
if object_type and callable_name and "." in callable_name:

0 commit comments

Comments
 (0)