A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/typeddjango/django-stubs/issues/1684 below:

`type[Model]` no longer allows access to `.objects` in `django-stubs` 4.2.4 · Issue #1684 · typeddjango/django-stubs · GitHub

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

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4