2 ms·
Yea 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
by mnarayan01 9y ago
Yea 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.