3 ms·
If you do the work suggested in https://www.jetbrains.com/help/pycharm/type-hinting-in-pycharm.html https://www.jetbrains.com/help/pycharm/type-hinting-in-pycha
by mnarayan01 9y ago
If you do the work suggested in https://www.jetbrains.com/help/pycharm/type-hinting-in-pycharm.html https://www.jetbrains.com/help/pycharm/type-hinting-in-pycha... which references https://www.python.org/dev/peps/pep-0484/ https://www.python.org/dev/peps/pep-0484/ and https://www.python.org/dev/peps/pep-0526/ https://www.python.org/dev/peps/pep-0526/ then it can do a pretty good (though not perfect) job. That said...getting it there can take quite a bit of work, particularly w.r.t. third-party libraries.
- jorgemf 9y agoThanks. Not sure if it is useful for me as I still have to use python 2.7 UPDATE: I didn't see the python stubs, that made my day! lot of thanks for it!
- mnarayan01 9y agoYea I'm in the same boat. It's nice, though there are definitely warts. For third-party stuff stubs are a big help. For stuff I'm actively working on I've found comments/docstrings (I've used reStructuredText) to be useful: self.ivar = 1 # type: int self.ivar = [1] """ :type: list[int] """ def fun(arg1, arg2): # type: (int, str) -> str def fun(arg): """ :param int or str arg: :rtype: str or None """ I like the comment version (e.g. `# type: int`) better (plus its officially defined in PEP 484), but sadly they tend not to work as well, sometimes due to not being able to `import typing`, and sometimes for other less clear reasons.