Skip to content

Several insert/update methods are not type checking model fields #1307

Open
@Kangaroux

Description

@Kangaroux

Bug report

Model.objects.create() will correctly type check the kwargs for field names and types, whereas Model.objects.get_or_create() does not. Notice how mypy catches the first line but misses the second (vscode plugin, mypy CLI gives the same output)

image

These methods are affected:

  • acreate
  • aget_or_create
  • aupdate
  • aupdate_or_create
  • get_or_create
  • update
  • update_or_create

Many of the queryset methods are also missing field name checking, such as distinct, exclude, in_bulk, etc. (not sure if this is possible due to query annotations)

System information

  • OS: PopOS 22.04
  • python version: 3.10.6
  • django version: 4.0.7
  • mypy version: 0.991
  • django-stubs version: 1.13.0
  • django-stubs-ext version: 0.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requestmypy-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