] > Re: [Python-projects] pylint: Warning about relative imports (Logilab.org)

Email Re: [Python-projects] pylint: Warning about relative imports

from
Marc 'BlackJack' Rintsch <marc at rintsch dot de>
subject
Re: [Python-projects] pylint: Warning about relative imports
date
2005/10/20 10:13
On Wednesday 19 October 2005 21:21, Nicolas Chauvat wrote:
> On Wed, Oct 19, 2005 at 04:58:53PM +0100, Gustavo J. A. M. Carneiro 
wrote:
> >   Hello,
> >
> >   I'm getting really tired of seeing warnings like this:
> >
> > /mnt/labipsrc/gjc/qosal.src/discovery.py:3: [W] Relative import
> > 'protocol'
> >
> >   As far as I know, there is no implementation of relative/absolute
> > imports in Python (I forget the PEP number).  The PEP was accepted
> > by the BDFL, but no one implemented it in Python/C.  Therefore, why
> > is pylint warning about something that is impossible to fix?  How
> > can I make it shut up?
>
> There are many solutions to your problem:
>
> 1. do not use pylint. it will stop bothering you.
>
> 2. write your own pylint tool that will do exactly what you want.
>
> 3. read the documentation: --disable-msg=W0403
>
> And remember that what pylint is not citing the law, it is only
> trying to help finding potential problems with your code AND it is
> entirely configurable.

4. Don't use relative imports.

The only situation where this warning is a bit annoying is when you 
import a modul from the same directory and that directory isn't a 
package.  Maybe it's possible for `pylint` to check for a `__init__.py` 
and suppress the warning if it's not there!?

Ciao,
Marc 'BlackJack' Rintsch
-- 
“The last good thing written in C was
 Franz Schubert's Symphony number 9.” -- Michael Hodous

is a reply to