Skip to content
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

Don't crash when inspecting classes loaded from cache #2185

Merged
merged 1 commit into from
May 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mypy_django_plugin/transformers/models.py
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
CallExpr,
Context,
Expression,
FakeInfo,
NameExpr,
RefExpr,
Statement,
@@ -640,6 +641,10 @@ def statements(self) -> Iterable[Statement]:
while model_bases:
model = model_bases.popleft()
yield from model.defs.body
if isinstance(model.info, FakeInfo):
# While loading from cache ClassDef infos are faked and 'FakeInfo' doesn't have
# all attributes of a 'TypeInfo' set. See #2184
continue
for base in model.info.bases:
# Only produce any additional statements from abstract model bases, as they
# simulate regular python inheritance. Avoid concrete models, and any of their