[wingide-users] Feature request: manual inline type annotation

Linos info at linos.es
Sat Oct 1 12:54:57 MDT 2011

El 01/10/11 20:49, Wingware Support escribió:
> On 10/1/11 11:05 AM, Linos wrote:
>>     to be frank i am not sure if something like this it is supported already in
>> WingIDE but i would find incredible useful.
>> Many times i have a method that receives objects as parameters or i assign a
>> variable to the return of other object method implemented in different modules
>> that WingIDE can't find the type so i lost autocomplete and source assistant
>> features, would be great that when this happen i could help Wing to determine
>> the type of the variable.
>> i have used in the past .pi files but don't know if i can use to define the
>> types of variables inside classes methods and if it is a good idea anyway, i
>> would prefer something inline. I have checked the standard function annotations
>> in Python3 but i am still in Python2 and this would not help with the second
>> case anyway.
>> I am not sure what syntax would be fine but something like epydoc or numpydoc
>> would be probably fine for functions and methods and for variables something
>> commented after the variable?
>> new_object = other_module.other_class.getOBject() #@type new_object:
>> other_module.other_type
> You can do this with the following:
> isinstance(new_object, other_module.other_type)
> If you need to do this in a way that isn't seen by Python at runtime or to avoid
> circular imports you can do this:
> if 0:
>   import whatever
>   isinstance(obj, whatever.something)
> Wing ignores the conditional in doing static type analysis.
> Also note that running to a breakpoint lets Wing use the live runtime state of
> the debug process to get type information, if you're working in code that's on
> the stack.
> Hope that's useful,

Yes this will help but still i think that would be better for Wing to support
any type of annotations in comments than force me to write a bunch of false
isinstance in my code, anyway i will make use of this, thanks.

Miguel Angel.

More information about the wingide-users mailing list