This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kj
Recipients gvanrossum, kj, serhiy.storchaka
Date 2021-08-01.07:55:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627804502.89.0.296522722542.issue44801@roundup.psfhosted.org>
In-reply-to
Content
> Type expression is coerced to a list of parameter arguments in substitution of ParamSpec.

It's not, only the repr is like that. Internally it's not coerced.

>>> C[int, str]
typing.Callable[[int], str]
>>> C[int, str].__args__
(<class 'int'>, <class 'str'>)

Because Callable's correct form is Callable[[type], type] (where type is not ParamSpec or Concatenate) so the repr reflects that.

Internally, Callable also flattens the list of args:

>>> Callable[[int, str], int].__args__
(<class 'int'>, <class 'str'>, <class 'int'>)

Because __args__ *must* be hashable and immutable. Otherwise, it will not work with Union or Literal. Some time ago we tried converting to nested tuple. But that was too difficult (and backwards incompatible) because every other typing operation expected __args__ to contain types, not a tuple.
History
Date User Action Args
2021-08-01 07:55:02kjsetrecipients: + kj, gvanrossum, serhiy.storchaka
2021-08-01 07:55:02kjsetmessageid: <1627804502.89.0.296522722542.issue44801@roundup.psfhosted.org>
2021-08-01 07:55:02kjlinkissue44801 messages
2021-08-01 07:55:02kjcreate