Code Completion
Type hinting with docstrings/comments
New on PyDev 2.8.0
It's possible to provide hints for code-completion with docstrings by commenting types with the Sphinx/Epydoc format.Below are some examples of how to provide type-hints.
Return type with Sphinx
class MyClass: def method(self): ':rtype unittest.TestCase'
Parameter type with Sphinx
class MyClass: def method(self, a): ':type a: TestCase' #Note that just the class name is accepted, but in this case, #it'll search for a TestCase class in the whole workspace
Parameter type with Sphinx inline
class MyClass: def method(self, a): ':param TestCase a:'
Local variable with Sphinx
class MyClass: def method(self, lst): #Can be on the same line for a in lst: #: :type a: GUITest a.;
Local variable with Sphinx
class MyClass: def method(self, lst): #Or on the line before #: :type a: GUITest for a in lst: a.;
Local variable with Sphinx
class MyClass: def method(self, lst): #If commented as a docstring must be on the #line after for a in lst: ': :type a: GUITest' a.;
Return type with Epydoc
class MyClass: def method(self): '@rtype unittest.TestCase'
Parameter type with Epydoc
class MyClass: def method(self, a): '@type a: TestCase' #Note that just the class name is accepted, but in this case, #it'll search for a TestCase class in the whole workspace
No comments:
Post a Comment