bhch / django-jsonform

A better, user-friendly JSON editing form field for Django admin. Also supports Postgres ArrayField.
https://django-jsonform.rtfd.io
BSD 3-Clause "New" or "Revised" License
352 stars 34 forks source link

Type annotations / stubs #170

Open H4rryK4ne opened 5 months ago

H4rryK4ne commented 5 months ago

Did you ever consider adding type annotations or creating stubs for type checking?

bhch commented 5 months ago

I personally don't use typing so I don't mind its absence.

However, if you or someone else wants to contribute, I'd merge it provided that it won't be too much hassle for me to maintain in the future.

H4rryK4ne commented 2 months ago

I wanted to start now with type annotations.

Currently you support python down to version 3.4. How important is this to you?

The typing module is part of the standard packages from 3.5. Type annotations became actually usable with 3.9+.

There a two approaches we could use:

  1. I do the type annotations directly in the library.
    • PRO: easy to maintain as everything is in the base package
    • CON: minimum python version would increase to 3.9
  2. I create an extra pypi package with the stubs
    • PRO: your code won't be touched
    • CON: harder to maintain, as every change to the original code needs to be mirrored in the stub package

In October this year Python 3.8 will be end-of-live ... (https://devguide.python.org/versions/), so I personally would go with option 1.

Which approach would you prefer?

bhch commented 2 months ago

The minimum I can go right now is Python 3.6.

Here are some estimated download stats for django-jsonform:

Python version Downloads
3.6 ~100/mo
3.7 ~2,000/mo
3.8 ~7,000/mo

So, I don't think it would be wise to just drop everything below 3.9 without doing a major release.

I'm planning a major v3 (in a couple of months). So maybe then we can drop support for Python < 3.9.

I think for the time being, you should create a third party package for the stubs and we might merge it in v3.
Until then I can mention your library in the Docs and the Readme for people looking for typing support.

CON: harder to maintain, as every change to the original code needs to be mirrored in the stub package

The backend code rarely changes in django-jsonform. I don't think that would be too much work between updates.

H4rryK4ne commented 1 month ago

I created a repo with the stub files ... I have not yet published a package yet ...

https://github.com/H4rryK4ne/django-jsonform-stubs