typeshed
typeshed copied to clipboard
Evaluate or document how to merge type stubs into existing codebase
To simplify adoption of type hints in upstream repositories, this issue looks to better understand how maintainers upstream of typeshed can merge existing type stubs into their codebase.
In order to adopt inline type hints, upstream maintainers as I understand it currently need to manually merge existing stubs into their codebase.
To simplify the process, is there a tool to merge existing stubs into a project's codebase for faster adoption?
If so, is there documentation for it?
If not, is this something g that's worth evaluating and creating?
To simplify the process, is there a tool to merge existing stubs into a project's codebase for faster adoption?
pytype's merge_pyi
tool does this: https://github.com/google/pytype/tree/main/pytype/tools/merge_pyi
There's an effort to improve documentation of Python-typing/typeshed etc. at https://typing.readthedocs.io/en/latest/index.html#. I don't know that pytype's merge_pyi
tool is mentioned there, and it might be a useful thing to mention. If you'd like to improve that documentation, the source code is hosted at https://github.com/python/typing, and contributions are very welcome.
You might also be interested in @JelleZijlstra's autotyping
tool: https://github.com/JelleZijlstra/autotyping
retype and libcst can also do this
#8575 adds a more prominent link to https://typing.readthedocs.io/en/latest/index.html# to typeshed's README. I think any further documentation on this subject should go to that site rather than anywhere in the typeshed repo, so I propose closing this issue if that PR gets merged.
I think that's reasonable.
In my opinion, it'd make sense to create an issue in the website's repository to add a section, similar to type checkers, for how this can be done. That's certainly not the only solution, but could be a starting point to get the ball rolling.
In my opinion, it'd make sense to create an issue in the website's repository to add a section, similar to type checkers, for how this can be done. That's certainly not the only solution, but could be a starting point to get the ball rolling.
Sounds like a great idea! Feel free to make a PR over at https://github.com/python/typing, where that documentation is hosted :)