Re: pyflakes and star imports

Phil Frost <[email protected]> Fri, 11 Jul 2008 08:51:51 -0400
Newsgroups gmane.comp.python.quotient.dev
Message-ID <[email protected]>
On Jul 11, 2008, at 7:27 AM, Jean-Paul Calderone wrote:

> On Thu, 10 Jul 2008 23:34:39 +0200, Manlio Perillo <[email protected] 
> > wrote:
>> Hi.
>>
>> I'm starting to use pyflakes, with satisfaction, thanks for this  
>> tool!
>>
>> However some times I use star imports, but of course making sure  
>> that the imported module defines the special __all__ name.
>>
>> Unfortunately pyflakes simply bail out when it sees a star import.
>> Is it possible to make it look at the __all__ name in the imported  
>> module?
>>
>
> It's impossible to reliably determine the value of __all__ without  
> executing
> the code in the module.  It's possible to guess and probably be  
> right most of
> the time by looking at the AST very carefully.  If you want, you  
> could submit
> a patch for this.  Or you could break yourself of the bad habit of  
> using import
> *. :)

There is also the problem of finding the source of the module being  
imported. It's not as easy as it seems.