Skip to content

mypy crashes with KeyError: 'django_stubs_ext' when using django-stubs 1.9.0 #701

Closed
@pandabuilder

Description

@pandabuilder

Bug report

mypy crashes when reaching code with Django queries that annotate fields, which did not happen which django-stubs version 1.8.0.

What's wrong

viewer/models.py:951: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.910
viewer/models.py:951: : note: use --pdb to drop into pdb
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 3911, in accept
  File "mypy/nodes.py", line 1558, in accept
  File "mypy/checkexpr.py", line 271, in visit_call_expr
  File "mypy/checkexpr.py", line 353, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 858, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 917, in check_call
  File "mypy/checkexpr.py", line 1029, in check_callable_call
  File "mypy/checkexpr.py", line 738, in apply_function_plugin
  File "/home/gitlab-runner/builds/b5691a72/0/acctest/proj/ENV/lib/python3.9/site-packages/mypy_django_plugin/transformers/querysets.py", line 231, in extract_proper_type_queryset_annotate
    annotated_type = get_or_create_annotated_type(api, model_type, fields_dict=fields_dict)
  File "/home/gitlab-runner/builds/b5691a72/0/acctest/proj/ENV/lib/python3.9/site-packages/mypy_django_plugin/transformers/models.py", line 447, in get_or_create_annotated_type
    model_module_file = api.modules[model_module_name]  # type: ignore
KeyError: 'django_stubs_ext'

How is that should be

I Just upgraded from 1.8.0 to 1.9.0, and it was working without errors before upgrading.

System information

  • OS: Ubuntu 18.04.5 LTS
  • python version: 3.9.1
  • django version: 3.2.7
  • mypy version: 0.910
  • django-stubs version: 1.9.0

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