[wingide-users] Working with frameworks that dynamically import

Wingware Support support at wingware.com
Wed Dec 17 10:02:49 EST 2014


Joshua J. Kugler via wingide-users wrote:
> I know there are ways to give Wing hints about types (asserts, etc) but I
> don't want to do that for every object I use in every file I create.
>
> Is there a way to convince Wing to discover these dynamic imports?

One way to work around this is to run to a breakpoint and then edit.  
When the debugger is active, Wing uses both live runtime state and 
static analysis to fill the auto-completer, source assistant, etc.  This 
is my preferred way to work, for more reasons than just working around 
limitations in static analysis.  You can also immediately try things out 
in the live runtime state using the Debug Probe.

Another idea would be to do something like this before your normal 'from 
flask.ext.login import login_user' import:

if 0:
   from flask_login import login_user

A third more complicated idea is to try to use *.pi files as documented 
at https://wingware.com/doc/edit/helping-wing-analyze-code -- in this 
case, you'ld be copying flask files to different names under a package 
flask and sub-package ext in the pi-files directory of your user 
settings directory (which listed 5th in Wing's About box).  So you would 
have something like:

pi-files/flask
pi-files/flask/__init__.pi (empty file)
pi_files/flask/ext
pi-files/flask/ext/__init__.pi (empty file)
pi-files/flask/ext/flask_login.pi (which is flask_login.py renamed)

I don't know if that'll work well or not, depending on how the modules 
import each other, or if it's a pain to set up and keep updated 
(presumably would do that w/ a script).

I hope that helps.  Please let me know if you have other questions.

Thanks,

-- 

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com



More information about the wingide-users mailing list