Skip to content

no section [tool.django-stubs] found #2912

@asarkar

Description

@asarkar

Bug report

What's wrong

Running mypy with DJANGO_SETTINGS_MODULE=mysite.settings and [tool.django-stubs] section missing in pyproject.toml fails:

(config)
...
[tool.django-stubs]
django_settings_module = str (default: `os.getenv("DJANGO_SETTINGS_MODULE")`)
strict_settings = bool (default: true)
strict_model_abstract_attrs = bool (default: true)
...

(django-stubs) mypy: error: no section [tool.django-stubs] found

To fix this, an empty [tool.django-stubs] sections needs to be created.

plugins = ["mypy_django_plugin.main"]

[tool.django-stubs]
# intentionally left empty, `django_settings_module` will be read from DJANGO_SETTINGS_MODULE env var

How is that should be

User shouldn't need to set a useless empty section. Only fail is [tool.django-stubs] is missing and DJANGO_SETTINGS_MODULE is not set.

System information

  • OS: n/a
  • python version: 3.14.0
  • django version: 5.2.8
  • mypy version: 1.18.2
  • django-stubs version: 5.2.7
  • django-stubs-ext version: 5.2.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmypy-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