Skip to content

JSONField encoder type issue #75

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

Closed
lpil opened this issue Dec 6, 2021 · 1 comment · Fixed by #77
Closed

JSONField encoder type issue #75

lpil opened this issue Dec 6, 2021 · 1 comment · Fixed by #77
Labels
bug Something isn't working

Comments

@lpil
Copy link

lpil commented Dec 6, 2021

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
Copy link
Owner

sbdchd commented Dec 10, 2021

Oh yeah that makes sense

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

@sbdchd sbdchd added the bug Something isn't working label Dec 10, 2021
@kodiakhq kodiakhq bot closed this as completed in #77 Dec 11, 2021
kodiakhq bot pushed a commit that referenced this issue Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants