-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
AssertionError: Internal error: too many class plugin hook passes #15004
Comments
Here's a smaller reproducer: from dataclasses import dataclass
from typing import Protocol
@dataclass
class TargetSettings(Protocol):
min: int
def __post_init__(self) -> None:
self.min = int(self.min) Combining |
I do understand that How it happened in this case:
|
This comment was marked as spam.
This comment was marked as spam.
One of the reasons to dive deep into Python |
This comment was marked as spam.
This comment was marked as spam.
Fix #15004 FWIW I don't think dataclass protocols make much sense, but we definitely should not crash. Also the root cause has nothing to do with dataclasses, the problem is that a self attribute assignment in a protocol created a new `Var` (after an original `Var` was created in class body), which is obviously wrong.
Crash Report
See the traceback.
Traceback
To Reproduce
Your Environment
None
mypy.ini
(and other config files):None
3.10.9
Windows 11 22621.1413
Additional Comment
Let me say that I do believe that the concept of static type checking of
Union
is broken (again: the concept). In my very humble opinion as user, if I do declare something as aUnion
(either with the keyword or the|
operator),mypy
must believe that when the time comes, the variable/attribute declared as a Union, will contain one of the types.Reporting errors like
when the
Union
containsUnion[Decimal, str, int, float]
is in my very humble opinion: wrong. Such an error can be reported during runtime, but not during static analysis, becausemypy
has no way of knowing what the type at that stage contains. Reporting a "warning" would be ok. Reporting an "error" is an error itself.No, as a user I am not in the mood of adding
cast
here and there and here-there to pollute the code, hence the need to add a# type: ignore
to silencemypy
.The text was updated successfully, but these errors were encountered: