Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'warnings': 0.04; "'',": 0.07; 'framework.': 0.09; 'imported': 0.09; 'indicates': 0.09; 'okay': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'references.': 0.09; 'suppress': 0.09; 'subject:How': 0.10; 'django': 0.11; 'def': 0.12; 'adam': 0.16; 'magic': 0.16; 'obviously,': 0.16; 'pep8': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'urls.py': 0.16; 'wrote:': 0.18; 'module': 0.19; 'seems': 0.21; 'import': 0.22; 'header:User-Agent:1': 0.23; 'shown': 0.26; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'code': 0.31; 'serve': 0.31; 'file:': 0.31; 'file': 0.32; 'checked': 0.32; 'totally': 0.33; 'comment': 0.34; 'but': 0.35; 'there': 0.35; 'false': 0.36; 'wrong': 0.37; 'application': 0.37; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'new': 0.61; 'show': 0.63; 'such': 0.63; 'more': 0.64; 'within': 0.65; "'view'": 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: How to avoid PEP8 'imported but unused' Date: Sun, 05 May 2013 18:38:46 +0200 Organization: None References: <20130505160054.GA10521@capricorn> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p508497f3.dip0.t-ipconnect.de User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367771933 news.xs4all.nl 15874 [2001:888:2000:d::a6]:46781 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44753 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...