Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44754
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jiang.adam@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'anyway.': 0.05; 'importing': 0.05; "'',": 0.07; 'framework.': 0.09; 'imported': 0.09; 'indicates': 0.09; 'okay': 0.09; 'references.': 0.09; 'subject:How': 0.10; 'django': 0.11; 'def': 0.12; 'question.': 0.14; 'obviously,': 0.16; 'pep8': 0.16; 'silence': 0.16; 'urls.py': 0.16; 'wrote:': 0.18; 'module': 0.19; 'thanks.': 0.20; 'seems': 0.21; 'import': 0.22; 'cc:addr:gmail.com': 0.22; 'header:User-Agent:1': 0.23; 'module,': 0.24; 'cc:2**0': 0.24; 'shown': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'serve': 0.31; 'usually': 0.31; '+0100,': 0.31; 'assert': 0.31; 'file:': 0.31; 'file': 0.32; 'checked': 0.32; 'url:python': 0.33; 'totally': 0.33; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'wrong': 0.37; 'application': 0.37; 'received:209': 0.37; 'generic': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'skip:u 10': 0.60; 'new': 0.61; 'content-disposition:inline': 0.62; 'show': 0.63; 'received:122': 0.63; 'more': 0.64; 'within': 0.65; 'side': 0.67; 'safe': 0.72; 'counts': 0.83; "'view'": 0.84; '05,': 0.84; 'effects,': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=wocZOBpk/hM7WxIh/LIL5VDslDF8HVza+xaJmclALWo=; b=YZMaAyGYWzLLzI3d4bGDJLa2XIn3S5oH7ESqpp7O6bsqFUICBQs4nsLOODPeIX7NHa rF5A7dwgpO8+F2FcLJFZckBusa4f7axs4k6b2GnqK6xLcUOWd4PwKgzNXWXigKVpXl83 HfjKbhworN1f43/uBz7K4OYTdGGQ66kplHP2gPaQQA8A5uOZ2QaVzSKcix2dp7fsCru2 1Od5Ucm/kMvAPhk6MDz0qMD4GQdpfNL9C9VkM+OgxyGoOcYHMHnwiHCp0Hf+XOcpTT1a hN6/b0AjUp5nPDtMkFWgGoYb9UeYX9fg38fDwUWnps0hdPuIsln+0iJbTCjHFVS4qMGO t6uQ== |
| X-Received | by 10.68.198.99 with SMTP id jb3mr17908086pbc.195.1367772036740; Sun, 05 May 2013 09:40:36 -0700 (PDT) |
| Date | Mon, 6 May 2013 01:40:31 +0900 |
| From | Adam Jiang <jiang.adam@gmail.com> |
| To | python-list@python.org |
| Subject | Re: How to avoid PEP8 'imported but unused' |
| References | <20130505160054.GA10521@capricorn> <CAA=1kxT6M_wn7Ek+RAN9Zo1KJ7T4sMdDgDd4LC1CqaRJkToNqQ@mail.gmail.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Disposition | inline |
| Content-Transfer-Encoding | 8bit |
| In-Reply-To | <CAA=1kxT6M_wn7Ek+RAN9Zo1KJ7T4sMdDgDd4LC1CqaRJkToNqQ@mail.gmail.com> |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1299.1367772046.3114.python-list@python.org> (permalink) |
| Lines | 51 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1367772046 news.xs4all.nl 15960 [2001:888:2000:d::a6]:48012 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44754 |
Show key headers only | View raw
Thanks. It works very well.
One more question. In this particular case it seems 'assert' should be
safe as a workaround, doesn't it? 'assert' will check if the symbol
is imported and not NULL. Is there side effect if I just applied this
rule as a generic one.
/Adam
On Sun, May 05, 2013 at 05:18:40PM +0100, Fábio Santos wrote:
> 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" <jiang.adam@gmail.com> 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?
> >
> > Best regards,
> > /Adam
> > --
> > http://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to avoid PEP8 'imported but unused' Adam Jiang <jiang.adam@gmail.com> - 2013-05-06 01:40 +0900
csiph-web