-
-
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
Generic bounded dataclass crash #10140
Comments
[edit by JukkaL: this is tracked in #12112] I've encountered similar crash:
Code to reproduce: from typing import TypeVar
def test() -> None:
T = TypeVar('T', bound='Foo')
class Foo:
def bar(self, foo: T) -> None:
pass
|
Here is a simplified version of the first example: from dataclasses import dataclass
from typing import Generic, TypeVar
T = TypeVar("T", bound="C")
@dataclass
class C(Generic[T]):
x: int |
I think I ran into this with a Django project as well. The following code seems to trigger a crash that seems related. T = TypeVar("T", bound="MyModel")
class MyModel(Generic[T], models.Model):
field = models.DateField(db_index=True) Oddly enough, it's specific to the field type. A CharField won't cause a crash. A DateField will.
|
Ran into the exact same issue as @dragonpaw - copy/pasting DateField and its parents into the file in which the model is defined resolves the issue, so it looks import-related |
The first example was fixed by #12762. The issue reported by @ethframe is different (but related). We should probably move it to another issue. I haven't looked into the issue reported by @dragonpaw and @Gallinaryoso. Are you using the mypy django plugin by any chance? |
Closing, since the original issue is fixed and we have another issue for ethframe's report. If you have a different issue that is not yet addressed, please open a new issue, since this one is getting confusing. |
Crash Report
Ran mypy on my user library - no idea what went wrong.
Traceback
To Reproduce
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: