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

Gene Campbell campbell.gene at gmail.com
Sat Oct 1 14:06:55 MDT 2011


Hi,

+ 1 on better auto complete/code intelligence.

I love Wing.  I enjoy using it.  It rocks!!!  Long live Wing!!

Now, I have been forced to use PyCharm for a client recently, and have
concluded it's really good, too.   PyCharm can do this without
littering the source with isinstance().  As much as I like Wing, I
don't think putting isinstance in my code is a reasonable ask for a
top quality professional IDE, so I don't do it.  I just dream of day
Wing can do this.

Gene



On Sat, Oct 1, 2011 at 11:49 AM, Wingware Support <support at wingware.com> wrote:
> 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
>
> www.wingware.com
>
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide
>


More information about the wingide-users mailing list