<p dir="ltr">I usually do this on pyflakes:</p>
<p dir="ltr">import whatever<br>
assert whatever # silence pyflakes</p>
<p dir="ltr">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.</p>
<p dir="ltr">On 5 May 2013 17:05, "Adam Jiang" <<a href="mailto:jiang.adam@gmail.com">jiang.adam@gmail.com</a>> wrote:<br>
><br>
> I am new to python. Now, I am woring on an application within Django<br>
> framework. When I checked my code with pep8 and pyflakes, some warning<br>
> messages show up-'Foobar imported but unused'. Obviously, it indicates<br>
> that some modules are imprted to current module but never get<br>
> references. However, it seems the message is wrong in this case:<br>
><br>
> # file: urls.py<br>
> urlpattens = patterns(<br>
> '',<br>
> url('^signup/$', 'signup')<br>
> }<br>
><br>
> # file: register.py<br>
> def signup(request):<br>
> return ...<br>
><br>
> # file: views.py<br>
> import signup from register<br>
><br>
> The warning message is shown in file views.py. It seems to me that the<br>
> code is okay because Django requires all functions serve as 'view' is<br>
> typically go into views.py. 'import' is about get 'signup' function<br>
> into module 'views.py'. Or, I am totally wrong? Is there a proper way<br>
> to avoid this warnning?<br>
><br>
> Best regards,<br>
> /Adam<br>
> --<br>
> <a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br>
</p>