atlassian-python-api icon indicating copy to clipboard operation
atlassian-python-api copied to clipboard

Add typeshed stubs for this project

Open Ry-DS opened this issue 2 years ago • 4 comments

Would be great if down the line, types are published onto typeshed to help mypy users importing this project. Or, the mypy config on this project could be changed to --strict, and collective effort is put into typing the project here (will force the project to only work on Python 3.5+)

Ry-DS avatar Jun 23 '22 02:06 Ry-DS

Hi @Ry-DS , do you mean in that way ? https://mypy.readthedocs.io/en/latest/stubs.html#stub-file-syntax Could you show some example please?

gonchik avatar Sep 17 '22 10:09 gonchik

The easiest way is to go through every file and add the definitions with the files like I did in #1031 (reverted in https://github.com/atlassian-api/atlassian-python-api/pull/1031/commits/e8babc0300b78a0365ad38df2185d4f98da231f0). Then, the types will update with the code as the project evolves. Another route is putting the stub files pyi in this repo itself, like described in the link you sent. They just have to be in the same location with the same name. I haven't used this myself but mypy should pick them up when the module is installed.

Another option to keep things separate from this repo is to make a PR in https://github.com/python/typeshed. Then users can download stubs with a simple pip command. This does mean you'll need to update this location manually. An example PR: https://github.com/python/typeshed/pull/5789/files

For the last 2 options, a useful tool is https://mypy.readthedocs.io/en/stable/stubgen.html, which can create a basic skeleton. The types can be updated from there.

Ry-DS avatar Sep 22 '22 03:09 Ry-DS