atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.32k stars 653 forks source link

Add typeshed stubs for this project #1001

Open Ry-DS opened 2 years ago

Ry-DS commented 2 years ago

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+)

gonchik commented 1 year ago

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?

Ry-DS commented 1 year ago

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.

MarcelWilson commented 2 months ago

Can I ask the obvious question; Is there a reason to still support python 2.7?
Because if there isn't, I'll create a PR with the typehints added right now.

bandophahita commented 2 months ago

I have a draft PR which adds typehints to primarily jira.py. Mypy identified some issues that I feel need to be addressed above my paygrade.

https://github.com/atlassian-api/atlassian-python-api/pull/1418/files