Skip to content
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

Type annotations / stubs #170

Open
H4rryK4ne opened this issue Jun 14, 2024 · 4 comments
Open

Type annotations / stubs #170

H4rryK4ne opened this issue Jun 14, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@H4rryK4ne
Copy link

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

@bhch bhch added the enhancement New feature or request label Jun 22, 2024
@bhch
Copy link
Owner

bhch commented Jun 22, 2024

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

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

bhch commented Sep 24, 2024

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants