-
-
Notifications
You must be signed in to change notification settings - Fork 517
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
What's wrong
Prior to django-stubs 4.2.4 / mypy 1.5.1, the you could type hint a variable/class attribute as type[Model] and access .objects on it:
from django.contrib.auth.models import User
from django.db.models import Model
user_type: type[Model] = User
users = user_type.objects.all()Note that is the real usage, the variable is a class variable that is set by derived classes.
But as of the latest django-stubs and mypy, this generates a type check error:
error: "type[Model]" has no attribute "objects" [attr-defined]
How is that should be
No type check errors.
System information
- OS: macOS
pythonversion: 3.10.11djangoversion: 4.2.5mypyversion: 1.5.1django-stubsversion: 4.2.4django-stubs-extversion: 4.2.2
Mypy configuration:
[tool.mypy]
ignore_missing_imports = true
strict = true
disallow_subclassing_any = false
disallow_untyped_decorators = false
warn_return_any = false
plugins = [
"pydantic.mypy",
"mypy_django_plugin.main",
]sidmitra, meshy, IoanStoianov, rob4226, totycro and 3 more
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working