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 serhiy.storchaka
Recipients gvanrossum, kj, serhiy.storchaka
Date 2021-08-03.17:46:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1628012764.61.0.155590008376.issue44801@roundup.psfhosted.org>
In-reply-to
Content
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")
>>> class Z(Generic[P]): pass
... 
>>> A = Z[[int]]
>>> B = Z[int]
>>> A
__main__.Z[(<class 'int'>,)]
>>> B
__main__.Z[int]
>>> A.__args__
((<class 'int'>,),)
>>> B.__args__
(<class 'int'>,)

It is expected that A and B should the same.
History
Date User Action Args
2021-08-03 17:46:04serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, kj
2021-08-03 17:46:04serhiy.storchakasetmessageid: <1628012764.61.0.155590008376.issue44801@roundup.psfhosted.org>
2021-08-03 17:46:04serhiy.storchakalinkissue44801 messages
2021-08-03 17:46:04serhiy.storchakacreate