Last Site Update: December 20th, 2024 | Latest Version: 12.2.0


Main

Download

Screenshots

Manual

Developers

About/Contact


PyDev LiClipse




Previous (Auto-suggest keywords) Root Next (Debugger)


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.

List type with Sphinx (PyDev 4.0 onwards)

Note: It works with brackets or parenthesis:

class MyClass:

    def method(self, param):
        ':type param: list(str)'
        ':type param: list[str]'

Dict type with Sphinx (PyDev 4.0 onwards)

Note: It works with brackets or parenthesis:

class MyClass:

    def method(self, param):
        ':type param: dict(str, MyClass)'
        ':type param: dict[str, MyClass]'

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




Previous (Auto-suggest keywords) Root Next (Debugger)

PyDev development

PyDev is open source and depends on your contributions! This may be in the form of bug fixes, answers on stackoverflow, new features...

Another option is financially supporting it at: Patreon (which provides a way to support it monthly and get rewards starting with $1).



Or through 1-time contributions at:

  Paypal




Search PyDev-related content







Copyright: Brainwy Software Ltda, 2014-2021