Skip to content

Commit 1c5c7f4

Browse files
committed
update spec wording
1 parent 8184529 commit 1c5c7f4

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

docs/spec/callables.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,19 @@ argument will be passed to the ``takes_name`` function.
415415

416416
Therefore, it is only safe to unpack a non-:term:`closed` TypedDict in a function call
417417
if that function has ``**kwargs`` in its signature, and any :term:`extra items` are assignable to the type of ``**kwargs``.
418-
419-
- If the function being called has ``**kwargs``, checkers should error if the TypedDict's :term:`extra items` are not assignable to the type of ``**kwargs``. For this rule, :term:`open` TypedDicts are treated as having extra items of type ``object``.
420-
- If the function being called does not have ``**kwargs``, checkers should error if the TypedDict is :term:`open`, and should error if the TypedDict declares non-``Never`` :term:`extra items`.
418+
For these rules, :term:`open` TypedDicts are treated as having :term:`extra items` of
419+
type ``object``.
420+
421+
- If the callee has non-unpacked ``**kwargs``, checkers should error if the TypedDict's
422+
:term:`extra items` are not assignable to the type of ``**kwargs``.
423+
- If the callee has unpacked ``**kwargs`` (``**kwargs: Unpack[TD]``), checkers should
424+
error if the TypedDict's :term:`extra items` are not assignable to ``TD``'s extra
425+
items, treating a :term:`closed` ``TD`` as accepting no extra items.
426+
- If the callee does not have ``**kwargs``, checkers should error if the TypedDict is
427+
:term:`open`, and should error if the TypedDict declares non-``Never``
428+
:term:`extra items`.
429+
430+
Additionally, the type of :term:`extra items` must be assignable to any keyword parameters the function call does not provide.
421431

422432
In cases similar to the ``bar`` function above the problem could be worked
423433
around by marking ``Animal`` with ``closed=True``, or by explicitly dereferencing desired

0 commit comments

Comments
 (0)