Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: comp.lang.python Subject: Re: pylint woes Date: Sun, 08 May 2016 16:12:20 +0200 Organization: None Lines: 34 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de 3vD2xoS1MqLaSHY+Mrsx7AbWKfhdlgrmnNFJT24TfLyQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'main()': 0.07; 'constants.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '2016': 0.16; 'dfs': 0.16; 'globals.': 0.16; 'naming': 0.16; 'parts.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'row': 0.16; 'simplifies': 0.16; 'wrote:': 0.16; 'variable': 0.18; 'arguments': 0.22; 'class,': 0.22; 'constant': 0.22; 'exceptions': 0.22; 'function,': 0.22; 'produces': 0.22; 'recognize': 0.22; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; 'chris': 0.26; 'values': 0.28; 'asks': 0.29; 'code': 0.30; 'convention': 0.30; 'problem': 0.33; 'smart': 0.33; 'handle': 0.34; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'smaller': 0.36; 'to:addr:python- list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'agree': 0.37; 'received:org': 0.37; 'seem': 0.37; 'does': 0.39; 'enough': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'received:de': 0.40; 'your': 0.60; 'determine': 0.61; 'course': 0.62; 'teach': 0.70; '"miles"': 0.84; 'blob': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57bd9e71.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:108352 Chris Angelico wrote: > On Sun, May 8, 2016 at 1:28 PM, DFS wrote: >> Invalid constant name "cityzip" (invalid-name) >> Invalid constant name "state" (invalid-name) >> Invalid constant name "miles" (invalid-name) >> Invalid constant name "store" (invalid-name) >> Invalid variable name "rs" (invalid-name) > > ... huh?? The first four seem to have been incorrectly detected as > constants. How are they used? As globals. pylint doesn't like it when you put your normal code outside a function, and I agree with the general idea. The problem is that it's not smart enough to recognize the exceptions like plus_one = make_adder(1) where plus_one obeys the naming convention for a function, but the linter asks you to change the line to PLUS_ONE = make_adder(1) In Row = collections.namedtuple("Row", "alpha beta") though pylint does recognize that collections.namedtuple() produces a class, so there might also be a way to teach it how to handle the custom factory. The OP should of course put the whole shebang into a main() function. That also simplifies it to determine which values should be passed as arguments when he breaks his blob into smaller parts.