Pydev Code Completion For Everything
Solution 1:
[Edit]
Since PyDev 2.8.0, it can use docstrings and comments to discover the type of objects.
See: http://pydev.org/manual_adv_type_hints.html for details on the supported formats.
[Before PyDev 2.8.0]
Previously, it only supported assert isinstance calls (and this still works):
assertisinstance(a_list, list)
PyDev will be able to recognize it and properly provide code-completion for it (note that you can run Python without the assertions later on if you find it's making your code slower: What does Python optimization (-O or PYTHONOPTIMIZE) do? )
Solution 2:
As of PyDev 2.8.0 can use Sphinx or Epydoc comments for code completion: http://pydev.org/manual_adv_type_hints.html
Solution 3:
If you use PyCharm, you can pick either epydoc or sphinx docstring style and specify types of parameters and function return values according to that style (further discussion)
Solution 4:
What I usually do to circumvent this.
deffunc(my_list_param):
my_list_param = []
my_list_param.appe # at this stage I would get code completion.
Just remember to delete the variable initialization when testing or committing. Oh and btw, the response marked as an answer doesn't seem to work for me.
Solution 5:
If you are using Python >= 3.5 in your code you can specify parameters type in function declarations (26.1. typing — Support for type hints), so you code could be:
from someobj import SomeObject
defsome_func(a_list: list, an_object: SomeObject):
a_list.app # Code completion works
an_object.a_method() # Code completion works
This type of syntax, has no effects on execution and does not make any check on the real type passed o the function, but make your code more readable and makes the code completion work.
Post a Comment for "Pydev Code Completion For Everything"