Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44801>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to