Skip to content

AssertionError: Type info for django.db.models.query._QuerySet missing #1323

Closed
@alexlatif

Description

@alexlatif

VScode mypy Django QuerySet error

Hi, I am not using anything out of the ordinary other than mypy and django-stubs. When my VScode runs mypy it crashes with this traceback below.

  File "/venv/lib/python3.11/site-packages/mypy_django_plugin/main.py", line 50, in transform_model_class
    process_model_class(ctx, django_context)
  File "/venv/lib/python3.11/site-packages/mypy_django_plugin/transformers/models.py", line 674, in process_model_class
    initializer_cls(ctx, django_context).run()
  File "/venv/lib/python3.11/site-packages/mypy_django_plugin/transformers/models.py", line 96, in run
    self.run_with_model_cls(model_cls)
  File "/venv/lib/python3.11/site-packages/mypy_django_plugin/transformers/models.py", line 377, in run_with_model_cls
    fallback_manager_info = self.get_or_create_manager_with_any_fallback()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/mypy_django_plugin/transformers/models.py", line 131, in get_or_create_manager_with_any_fallback
    fallback_queryset = self.get_or_create_queryset_with_any_fallback()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/venv/lib/python3.11/site-packages/mypy_django_plugin/transformers/models.py", line 181, in get_or_create_queryset_with_any_fallback
    assert base_queryset_info, f"Type info for {fullnames.QUERYSET_CLASS_FULLNAME} missing"
AssertionError: Type info for django.db.models.query._QuerySet missing

mypy almost always seems to crash with VScode open. I had originally patched files here

File "/venv/lib/python3.11/site-packages/mypy_django_plugin/transformers/models.py", line 155, in get_or_create_queryset_with_any_fallback

But it was a very crude way of getting it to work.

It does on occasion work for a few minutes (or at least not error) but I cannot seem to replicate its success on command.

I have been through several open and closed issues closely related but can't find anything similar to what I am facing.

I also don't know if this bug will be covered by this release. - #1316

Would be grateful for any help on this as its stopping my VScode from running mypy on my code and get a popup appear everytime I do a code change.

System information

  • OS: Mac M2 Ventura 13.1
  • python version: 3.11.0
  • django version: 4.1.4
  • mypy version: 0.991
  • django-stubs version: 1.13.0
  • django-stubs-ext version: 0.7.0
  • vscode version: 1.74.3
  • 'vscode-mypy-extension` version: v0.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcrash"Internal error" crashes from mypymypy-pluginIssues specific to mypy_django_plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions