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

Wingware Support support at wingware.com
Sat Oct 1 12:49:39 MDT 2011

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,


Stephan Deibel
Wingware | Python IDE
Advancing Software Development


More information about the wingide-users mailing list