-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
attrs plugin error: "The erased type of self '...*' is not a supertype of its class" on class definition with a generic using a constrained type variable, but then seems to work fine after definition #5542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Maybe the attrs plugin author (@euresti) can shed some insight? |
This may be related to #5263 (if not a duplicate). |
Just to clarify, both issues may be caused by bad interaction of patched |
Actually. I can repro with dataclasses too.
So it's related to the added |
OK, the problem is here and here where we unconditionally grab Also btw by agreement ids for generic functions/methods should have negative numbers. |
Would the solution just be to make the id |
After some thinking it seems to me just using |
By convention TypeVars for methods should have negative numbers. Since we're creating these methods we're guaranteed to have -1 free. Fixes python#5542
By convention TypeVars for methods should have negative numbers. Since we're creating these methods we're guaranteed to have -1 free. Fixes python#5542
The issue was caused because we were using 1 for the ids of the generated types. Since by convention TypeVars for methods should have negative numbers and we're creating these methods we're guaranteed to have -1 free. So use that instead. Fixes #5542
Consider the following example:
My expectation here would be a revealed type of
A[W*]
, which I do get.But I also get an error on the
@attr.s
definition:if I remove the constraints on
T
, (i.e.T = TypeVar("T")
) then the errors go away.The text was updated successfully, but these errors were encountered: