Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: How to avoid PEP8 'imported but unused'

Thread Tools

Re: How to avoid PEP8 'imported but unused'

Fábio Santos
Posts: n/a
I usually do this on pyflakes:

import whatever
assert whatever # silence pyflakes

Pyflakes and pep8 have no way of knowing django will import and use your
module, or whether you are just importing a module for the side effects, so
they issue a warning anyway. Assert'ing counts as using the module, so it
counts as an used import.

On 5 May 2013 17:05, "Adam Jiang" <(E-Mail Removed)> 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:
> urlpattens = patterns(
> '',
> url('^signup/$', 'signup')
> }
> # file:
> def signup(request):
> return ...
> # file:
> import signup from register
> The warning message is shown in file It seems to me that the
> code is okay because Django requires all functions serve as 'view' is
> typically go into 'import' is about get 'signup' function
> into module ''. Or, I am totally wrong? Is there a proper way
> to avoid this warnning?
> Best regards,
> /Adam
> --

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid PEP8 'imported but unused' Adam Jiang Python 0 05-05-2013 04:00 PM
Re: How to backup iPhone contacts to Computer, backup iPhone contactsphotos to computer ASP .Net Mobile 0 04-09-2013 10:46 AM
Re: How to subclass a family Devin Jeanpierre Python 0 04-08-2013 11:22 PM
Re: How to subclass a family Arnaud Delobelle Python 0 04-08-2013 09:17 PM
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM