Re:Things to use in Python 3
by NelsonMinar on Wednesday May 15, 2019 @10:22AM
(#19919638)
I'm sort of sad that Python has reinvented .h files.
Re:Things to use in Python 3
by ASalazarMX on Wednesday May 15, 2019 @01:32PM
(#19921763)
Same here. Fortunately those files are entirely optional and apparently seldomly used, judging by the limited IDE support after 5 years.
Re:Things to use in Python 3
by DonaldPShimoda on Wednesday May 15, 2019 @12:44PM
(#19921207)
Whoa, that's neat! I had no idea!
Does PyCharm support these? Like if I write the stub files manually, will type hints and autocompletion work correctly in the main file? This could be a great way to reduce the amount of syntactic overhead, at least in function definitions and top-level code.
Re:Things to use in Python 3
by BerislavLopac on Thursday May 16, 2019 @07:23AM
(#19927952)
At the moment, you can click on a (say) class definition, and, if it has the corresponding entry in the pyi file, it will open it. But I would like it to be a bit more integrated.
Another advantage is that you can use pyi files for static checking, but remove them when deploying the application.
Unfortunately the IDE support for those files (.pyi extension) is quite limited -- I have even suggested to the PyCharm team to implement an option to automatically save all annotations to stub files, while still displaying them alongside the code in the editor.
[0] https://www.python.org/dev/peps/pep-0484/#stub-files