Completing stunt code using PyDev as with PDT?

Is there any way to help complete PyDev code by specifying the type of the variable?

With PDT, you can use PHPDoc-like syntax for this purpose:

/* @var $my_var MyClass */
$my_var = myFunction();
// PDT is able to figure out that $my_var is a MyClass object.

But so far I can’t figure out how to do the same in python.

+3
source share
3 answers

No (see docs ). It seems that PyDev is replenishing imported materials and language keywords.

, . , , , pydev, . , , , ( ).

+1

, , assert isinstance()

:.

a = function()
assert isinstance(a, MyClass)
a. <- would get the proper completions

, Pydev , , , .

, , python -O ( )

+3

, , PyDev 2.2.2; ?

, , :

class Foo(object):
    def __init__(self, bar):
       self.bar = bar
       # Tricking PyDev
       if (not self.bar):
          self.bar = Bar()
          raise Exception("Bar should not be null")

, , - (, , )

+3

Source: https://habr.com/ru/post/1727541/


All Articles