django-stubs icon indicating copy to clipboard operation
django-stubs copied to clipboard

error: Missing type parameters for generic type "File"

Open mazlum opened this issue 3 years ago • 1 comments

Bug report

What's wrong

from django.core.files import File

def __call__(self, value: File) -> None:

Mypy says: Missing type parameters for generic type "File"

If I use like that:

def __call__(self, value: File[AnyStr]) -> None:

Result is: TypeError: 'type' object is not subscriptable

mazlum avatar Jul 15 '22 12:07 mazlum

This will be fixed in the next release of django-stubs-ext, see https://github.com/typeddjango/django-stubs/commit/e8d52fe7daf88cfe7db5d0dd312e1b5946577051. In the meantime, you can use the extra_classes argument of django_stubs_ext.monkeypatch().

ngnpope avatar Jul 15 '22 22:07 ngnpope

ngnpope said this should be fixed by #1050. Can this be closed now?

intgr avatar Nov 08 '22 12:11 intgr