[wingide-users] Force a return type for autosuggest

Steve Barnes gadgetsteve at hotmail.com
Fri Jul 18 01:03:24 EDT 2014


On 18/07/14 02:24, Diogo Baeder via wingide-users wrote:
> Hi guys,
>
> I'm having a problem which is, if I put a @classmethod in a class and 
> make it return an instance of that class (like returning "cls()" if 
> "cls" is the first parameter to the classmethod) WingIDE can't resolve 
> the return value to an instance of that class, hence I lose the 
> autosuggest that the IDE normally gives me in other situations.
>
> Do you know if there's a way to make WingIDE recognize the return 
> value as an instance of that class?
>
> Thanks!
> Diogo Baeder
> http://diogobaeder.com.br
>
>
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide
Diogo,

I seem to remember there being a tip that an *assert **isinstance* would 
do what you need, even if never executed, so if class C has a class 
method called GetOne that returns an instance of C then:

*if 0:**
**   c = **GetOne()**
**   assert isinstance(c, C)*

should do what you need.  If you only need the auto-complete to work for 
a short time then stopping the code in the debugger after c has been 
initialised and then doing your typing also works nicely.

Gadget/Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://wingware.com/pipermail/wingide-users/attachments/20140718/c92a749d/attachment.html>


More information about the wingide-users mailing list