Skip to content

dmypy crash in django project #21816

Description

@pai-martinreidemeister

Crash Report

I deleted a module with django models and now the mypy daemon crashes. I tried to clean the mess, but I am not yet finished, therefore I can't say what the root cause is.

Traceback

Please report a bug at https://github.com/python/mypy/issues
version: 2.3.0
Daemon crashed!
Traceback (most recent call last):
  File "mypy/dmypy_server.py", line 243, in serve
  File "mypy/dmypy_server.py", line 292, in run_command
    ret = method(self, **data)
  File "mypy/dmypy_server.py", line 360, in cmd_run
    return self.check(sources, export_types, is_tty, terminal_width)
  File "mypy/dmypy_server.py", line 434, in check
    res = self.initialize_fine_grained(sources, is_tty, terminal_width)
  File "mypy/dmypy_server.py", line 473, in initialize_fine_grained
    result = mypy.build.build(sources=sources, options=self.options, fscache=self.fscache)
  File "mypy/build.py", line 422, in build
  File "mypy/build.py", line 537, in build_inner
    graph = dispatch(sources, manager, stdout, connect_threads)
  File "mypy/build.py", line 4146, in dispatch
    process_graph(graph, manager)
  File "mypy/build.py", line 4614, in process_graph
    done, still_working, results = manager.wait_for_done(graph)
  File "mypy/build.py", line 1484, in wait_for_done
    process_stale_scc(graph, next_scc, self)
  File "mypy/build.py", line 4782, in process_stale_scc
    mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
  File "mypy/semanal_main.py", line 91, in semantic_analysis_for_scc
  File "mypy/semanal_main.py", line 200, in process_top_levels
    deferred, incomplete, progress = semantic_analyze_target(
  File "mypy/semanal_main.py", line 380, in semantic_analyze_target
    analyzer.refresh_partial(
  File "mypy/semanal.py", line 706, in refresh_partial
  File "mypy/semanal.py", line 733, in refresh_top_level
    self.accept(d)
  File "mypy/semanal.py", line 7734, in accept
    report_internal_error(err, self.errors.file, node.line, self.errors, self.options)
  File "mypy/errors.py", line 1384, in report_internal_error
  File "mypy/semanal.py", line 7732, in accept
    node.accept(self)
  File "mypy/nodes.py", line 1727, in accept
  File "mypy/semanal.py", line 1846, in visit_class_def
    self.analyze_class(defn)
  File "mypy/semanal.py", line 2078, in analyze_class
    self.analyze_class_body_common(defn)
  File "mypy/semanal.py", line 2139, in analyze_class_body_common
    self.apply_class_plugin_hooks(defn)
  File "mypy/semanal.py", line 2226, in apply_class_plugin_hooks
    hook(ClassDefContext(defn, base_expr, self))
  File "/path/to/my_project/.venv/lib/python3.13/site-packages/mypy_django_plugin/transformers/models.py", line 1100, in process_model_class
    initializer_cls(ctx, django_context).run()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/path/to/my_project/.venv/lib/python3.13/site-packages/mypy_django_plugin/transformers/models.py", line 105, in run
    self.run_with_model_cls(model_cls)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/path/to/my_project/.venv/lib/python3.13/site-packages/mypy_django_plugin/transformers/models.py", line 621, in run_with_model_cls
    self.process_relation(relation)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/path/to/my_project/.venv/lib/python3.13/site-packages/mypy_django_plugin/transformers/models.py", line 544, in process_relation
    through_fullname = helpers.get_class_fullname(relation.through)
  File "/path/to/my_project/.venv/lib/python3.13/site-packages/mypy_django_plugin/lib/helpers.py", line 214, in get_class_fullname
    return klass.__module__ + "." + klass.__qualname__
           ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute '__module__'. Did you mean: '__mod__'?```

To Reproduce

I don't know yet.

Your Environment

  • Mypy version used: 2.3.0
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
[tool.mypy]
strict = true
pretty = true
plugins = [
    "mypy_django_plugin.main",
    "mypy_drf_plugin.main",
]
  • Python version used: 3.13.12
  • Operating system and version: TuxedoOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions