Bug report
The objects manager seems to be weirdly mistyping the required iterable for bulk_create.
A Self type is required (which is OK), but this Self type is conflicting with the class type.
See minimal reproduction below.
What's wrong
# models.py
from django.db import models
class MyModel(models.Model):
pass
@classmethod
def test_bulk_create(cls) -> None:
created = [cls()]
cls.objects.bulk_create(created) # error: Argument 1 to "bulk_create" of "Manager" has incompatible type "list[MyModel]"; expected "Iterable[Self]" [arg-type]
How is that should be
The above code should not generate an error.
Using the "abstract model" mitigator _default_manager is working, but here the model is concrete (I tried with strict_model_abstract_attrs=false, which does not solve the issue).
The issue might be in the bounding of the objects attribute on subclasses (as it's deleted from the db/models/base.pyi Model stub).
System information
- OS: Windows 11
python version: 3.11.9
django version: 5.2.14
mypy version: 2.0.0
django-stubs version: 6.0.4
django-stubs-ext version: 6.0.4
[tool.mypy]
plugins = ["mypy_django_plugin.main"]
[tool.django-stubs]
django_settings_module = "test_mypy_django.settings"
(I tried with django-stubs/subs-ext: 5.2.9 and mypy 1.19, same outcome)
Bug report
The
objectsmanager seems to be weirdly mistyping the required iterable for bulk_create.A Self type is required (which is OK), but this Self type is conflicting with the class type.
See minimal reproduction below.
What's wrong
How is that should be
The above code should not generate an error.
Using the "abstract model" mitigator
_default_manageris working, but here the model is concrete (I tried withstrict_model_abstract_attrs=false, which does not solve the issue).The issue might be in the bounding of the
objectsattribute on subclasses (as it's deleted from thedb/models/base.pyiModel stub).System information
pythonversion: 3.11.9djangoversion: 5.2.14mypyversion: 2.0.0django-stubsversion: 6.0.4django-stubs-extversion: 6.0.4(I tried with django-stubs/subs-ext: 5.2.9 and mypy 1.19, same outcome)