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
bpo-44793: Arguments ignored in substitution in typing.Callable
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=<Date2021-08-04.21:00:34.993>created_at=<Date2021-08-01.07:08:58.391>labels= ['type-bug', 'library', '3.10', '3.11']
title='Type expression is coerced to a list of parameter arguments in substitution of ParamSpec'updated_at=<Date2021-08-04.21:00:34.992>user='https://github.com/serhiy-storchaka'
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.
Thank you Ken Jin. So the problem is the __args__ (x, str) is interpreted differently depending on x, and after substituting x the interpretation can be changed. If x was ParamSpec, it was interpreted in one way, but if it becomes int, it is now interpreted in other way.
The solution is to forbid substitution of P with wrong values (not parameters expression). Some normalization is also needed, before and after substitution.
Other related example is:
>>> from typing import*
>>> P = ParamSpec("P")
>>> classZ(Generic[P]): pass
>>> A = Z[[int]]
>>> B = Z[int]