-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
Maximum semantic analysis iteration count reached error with django-stubs 5.0.3 & 5.0.4 #2373
Comments
If I understand you correctly you can reproduce with the code you have? Essentially that your code triggers a regression between the versions? Could you perhaps run a You could also try out |
Correct. My next plan was indeed to do a |
I'm having the same issue fwiw, it starts like this:
Then it lists a bunch of my files, starting with this one: from __future__ import annotations
from enum import Enum
from typing import TYPE_CHECKING, TypeVar
if TYPE_CHECKING:
from pydantic import BaseModel
from foo import FooRequest
from bar import BaseBar
from baz import BaseBaz
BaseModelT = TypeVar("BaseModelT", bound="BaseModel")
BaseBarT = TypeVar("BaseBarT", bound="BaseBarModel", covariant=True)
BaseBazT = TypeVar("BaseBazT", bound="BaseBaz", covariant=True)
EnumT = TypeVar("EnumT", bound=Enum)
FooRequestT = TypeVar("FooRequestT", bound="FooRequest") (Redacted model names, apologies.) My best guess is that this used to barely work, and now is no longer working? Or it could be a red herring. 🤷 |
Sorry, I didn’t get the time to finish my explorations. Also, it’s a weird bug, because changing versions sometimes give me bugs with different configurations… |
Bisect complete:
It seems that the issue started with ac36393, though when I revert it on top of
I'm testing with Mypy 1.11.2, in case that's helpful -- unless I'm making some mistakes, it looks to me like this is specific django-stubs[-ext]. |
Interesting, I just triggered the same bug when upgrading dependencies in CI, even though django-stubs and django-stubs-ext are pinned. The only relevant changes:
Odd, I wonder if the same problem was merged into DRF-stubs? |
Ok, so I spent some time trying that out again this morning. 9a5ef9a seems to be the issue. Reverting it on top of master fixes the issue. I will read more about this commit and the issue mentioned in the comment to see if I can see what’s possible. |
Finding that the problematic commit was about managers and I’m trying to write a minimal reproduction, but I have a workaround in our case. |
Do you mean something like: class MyQuerySet(QuerySet[MyModel]):
...
MyManager = Manager.from_queryset(MyQuerySet)
class MyModel(Model):
objects = MyManager() |
Yes. More specifically, something like (but more complicated, because I’m inheriting from custom QuerySet and Manager): class MyQuerySet(models.QuerySet):
...
class MyManager(models.Manager):
...
class MyModel(models.Model):
objects = MyManager['MyModel'].from_queryset(MyQuerySet)
... I removed the It’s still unexpected that it would break because it used to be fine, but I’m not sure it’s a bug really. (I’m not saying "work", because I feel mypy was just ignoring some stuff that he’s now understanding and properly checking). |
Thanks! Do you have any advice on finding the culprit? The stack trace is huge, and I couldn't make sense of it, and I can't find anywhere that I'm doing anything like |
I think I've found it -- this seems to be correlated with the class MyModel(SafeDeleteModel, MyBaseModel): # type: ignore[django-manager-missing]
... |
Bug report
What's wrong
When running django-stubs 5.0.2, mypy goes through without error. But when updating django-stubs to 5.0.3, I’m getting the following error:
error: INTERNAL ERROR: maximum semantic analysis iteration count reached
.The traceback is huge, and not really helping, so my next step is to have a minimal reproduction, but I wanted to raise the bug in case someone else is running into this as well. I’ll also try to review what’s happening between the 2 versions to understand where the issue can be.
System information
python
version:django
version: 5.0.9 (but same error with 5.1.1)mypy
version: 1.11.2 (but same error with 1.10.1)django-stubs
version: 5.0.3django-stubs-ext
version: 5.0.3It works fine with:
django
version 5.1.1mypy
version 1.11.2django-stubs
version 5.0.2django-stubs-ext
version 5.0.2The text was updated successfully, but these errors were encountered: