Skip to content

Discrepancy between __args__ of typing.Callable and collections.abc.Callable #103452

Open
@AlexWaygood

Description

@AlexWaygood

On both Python 3.11 and main @ b57105a:

>>> import typing, collections.abc
>>> Ts = typing.TypeVarTuple("Ts")
>>> typing.Callable[[*Ts], None].__args__
(*Ts, <class 'NoneType'>)
>>> collections.abc.Callable[[*Ts], None].__args__
(*Ts, None)

According to this assertion in the test suite for typing.py, the behaviour of typing.Callable is correct here, whereas the behaviour of collections.abc.Callable is incorrect:

a = Callable[[*Ts], None]
b = Callable[[Unpack[Ts]], None]
self.assertEqual(a.__args__, (*Ts, type(None)))

However, the test is currently only run with typing.Callable, whereas it should be run with collections.abc.Callable as well.

Cc. @mrahtz, who wrote this test. This may also be of interest to @sobolevn :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13bugs and security fixesstdlibPython modules in the Lib dirtopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions