Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44753 > unrolled thread

Re: How to avoid PEP8 'imported but unused'

Started byPeter Otten <__peter__@web.de>
First post2013-05-05 18:38 +0200
Last post2013-05-05 18:38 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to avoid PEP8 'imported but unused' Peter Otten <__peter__@web.de> - 2013-05-05 18:38 +0200

#44753 — Re: How to avoid PEP8 'imported but unused'

FromPeter Otten <__peter__@web.de>
Date2013-05-05 18:38 +0200
SubjectRe: How to avoid PEP8 'imported but unused'
Message-ID<mailman.1298.1367771933.3114.python-list@python.org>
Adam Jiang wrote:

> I am new to python. Now, I am woring on an application within Django
> framework. When I checked my code with pep8 and pyflakes, some warning
> messages show up-'Foobar imported but unused'. Obviously, it indicates
> that some modules are imprted to current module but never get
> references. However, it seems the message is wrong in this case:
> 
> # file: urls.py
> urlpattens = patterns(
>     '',
>     url('^signup/$', 'signup')
> }
> 
> # file: register.py
> def signup(request):
>     return ...
> 
> # file: views.py
> import signup from register
> 
> The warning message is shown in file views.py. It seems to me that the
> code is okay because Django requires all functions serve as 'view' is
> typically go into views.py. 'import' is about get 'signup' function
> into module 'views.py'. Or, I am totally wrong? Is there a proper way
> to avoid this warnning?

pylint has a way to suppress such warnings with a comment like

from signup import register # pylint:disable=W0611

but personally I find the magic comment more annoying than the false 
warning...

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web