You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spec/callables.rst
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -415,9 +415,19 @@ argument will be passed to the ``takes_name`` function.
415
415
416
416
Therefore, it is only safe to unpack a non-:term:`closed` TypedDict in a function call
417
417
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.
421
431
422
432
In cases similar to the ``bar`` function above the problem could be worked
423
433
around by marking ``Animal`` with ``closed=True``, or by explicitly dereferencing desired
0 commit comments