-
-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing .objects
on variable typed type[Model]
gives error: type[Model]" has no attribute "objects"
#1685
Comments
.objects
on variable typed type[Model]
gives error: "type[LoggedModel]" has no attribute "objects".objects
on variable typed type[Model]
gives error: type[LoggedModel]" has no attribute "objects"
Duplicate of #1684 |
Ah, thanks. I'd argue the release notes should mention this as a possibly breaking change, since code that passed type checking before now fails. django-stubs 4.2.4 has this bullet point in the release notes:
but django doesn't seem to have changed their policy regarding What do you think? |
Yeah maybe we should've been more clear in the release notes. I think the bullet point aims for all prior 4.x versions of I'd argue that this improved alignment with the runtime justifies a breaking change. I'd say the new version just found a bug. And I don't think the behavior regarding |
.objects
on variable typed type[Model]
gives error: type[LoggedModel]" has no attribute "objects"
.objects
on variable typed type[Model]
gives error: type[Model]" has no attribute "objects"
I see how my last post was a bit ambiguous, I edited it to make it a bit clearer. In the end, I'm only suggesting to add an additional bullet point in the release notes, something along the lines of:
|
Done! |
After updating django-stubs from 4.2.3 to 4.2.4, this code:
produces this output when running
mypy test.py
:It passed typechecking with 4.2.3. According to django's documentation on Model attributes,
objects
should be accessible on models unless the model has a custom manager.The release notes for 4.2.4 don't indicate to me that this was changed. Was this change intentional? If yes, how should I annotate
test
above to make clear that it expects some model class with the defaultobjects
manager attribute?System information
python
version: 3.10.12django
version: 4.2.3mypy
version: 1.4.1django-stubs
version: 4.2.4django-stubs-ext
version: 4.2.2The text was updated successfully, but these errors were encountered: