sbdchd / django-types

:doughnut: Type stubs for Django
MIT License
202 stars 63 forks source link

JSONField encoder type issue #75

Closed lpil closed 2 years ago

lpil commented 2 years ago

Hello!

With the latest version JSONField has these properties:

    encoder: json.JSONEncoder = ...
    decoder: json.JSONEncoder = ...

However the Django documentation seems to say it should be the class constructor that is given, not an instance of the encoder class. This also seems to be what I've found in our codebase, both in hand written and generated code.

https://docs.djangoproject.com/en/3.2/ref/models/fields/#jsonfield

Should these fields be of this type?

    encoder: Callable[[], json.JSONEncoder] = ...
    decoder: Callable[[], json.JSONEncoder] = ...

Thanks

sbdchd commented 2 years ago

Oh yeah that makes sense

I think another way to write that is Type[json.JSONEncoder]