-
-
Notifications
You must be signed in to change notification settings - Fork 450
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
BaseFormSet - TypeError: 'type' object is not subscriptable #976
Comments
adding |
Try |
The original mypy error hasn't gone away (baseclass isn't a valid type), this is a test to reproduce the problem I'm dealing with, if you want, I can make a PR for it but I don't know if this is something that's even supposed to be possible or not:
|
It is a completely unrelated issue. The initial problem was with generics: What you're facing now is a known Another option is to declare your formset So, it would be great if you can open another issue targeting this problem ( |
I can see django-stubs/ext/django_stubs_ext/patch.py Lines 52 to 81 in d60e31e
Which means that it can be patched with The "I cannot use QuerySet or Manager with type annotations" section in the Closed via #909 |
Bug report
What's wrong
Having recently updated mypy and django-stubs, the following error started occurring:
This was pointing at my formset class, so I added the generic type and, as an example, had this:
Which appeased the type checker, but unfortunately resulted in the following runtime error:
This runtime error occurs even with the django_stubs_ext helper installed, as well as when using a string:
Note, this is running mypy with
--strict
, which enables--disallow-any-generics
.How is that should be
After adding the generic type to the formset class the type checker should pass and no runtime error should occur.
System information
python
version: 3.10.4django
version: 4.0.4mypy
version: 0.950django-stubs
version: 1.11.0django-stubs-ext
version: 0.4.0The text was updated successfully, but these errors were encountered: