FAQ
Howdy all,

A common idiom I use is::

def frobnicate(warble):
foo = complex_computation()
bar = long.access.path.leading.to.useful.value
baz = (lengthy + expression * with_several_parts)
spangulate("%(warble)s: %(foo)s%(bar)s [%(baz)d]" % vars())

This allows the format of the string to be clear, and allows the
separate parts of it to have meaningful names.

However, this is causing pylint to complain::

W:218:frobnicate: Unused argument 'warble'
W:219:frobnicate: Unused variable 'foo'
W:220:frobnicate: Unused variable 'bar'
W:221:frobnicate: Unused variable 'baz'

That is, pylint is not aware that the names used by accessing the values
from the dictionary returned by ?vars()?.

This warning, when it actually *does* detect unused name bindings, is
very useful; I don't want to disable it. Nor do I want to pepper my code
with hints to pylint about each one of these, detracting significantly
from the readability which is the main point of the above idiom.

How can I make pylint aware in the general case that the above idiom
does, in fact, constitute a use of the names ?warble?, ?foo?, ?bar?, and
?baz? in the code?

--
\ ?Pinky, are you pondering what I'm pondering?? ?I think so, |
`\ Brain, but if we give peas a chance, won't the lima beans feel |
_o__) left out?? ?_Pinky and The Brain_ |
Ben Finney

Search Discussions

  • Nicolas Chauvat at Jul 15, 2009 at 10:39 am
    Hi,
    On Wed, Jul 15, 2009 at 08:08:13PM +1000, Ben Finney wrote:
    def frobnicate(warble):
    foo = complex_computation()
    bar = long.access.path.leading.to.useful.value
    baz = (lengthy + expression * with_several_parts)
    spangulate("%(warble)s: %(foo)s%(bar)s [%(baz)d]" % vars())

    This allows the format of the string to be clear, and allows the
    separate parts of it to have meaningful names.

    However, this is causing pylint to complain::
    ...
    That is, pylint is not aware that the names used by accessing the values
    from the dictionary returned by ?vars()?.
    ...
    You are not the only one:
    http://lists.logilab.org/pipermail/python-projects/2009-July/thread.html

    Here is the ticket:
    https://www.logilab.net/elo/ticket/9634

    Thanks for the report. As usual, help and patches are welcome.

    --
    Nicolas Chauvat

    logilab.fr - services en informatique scientifique et gestion de connaissances
  • Ben Finney at Jul 15, 2009 at 11:01 am

    Nicolas Chauvat <nicolas.chauvat at logilab.fr> writes:
    On Wed, Jul 15, 2009 at 08:08:13PM +1000, Ben Finney wrote:
    That is, pylint is not aware that the names used by accessing the values
    from the dictionary returned by ?vars()?.
    ...
    You are not the only one:
    http://lists.logilab.org/pipermail/python-projects/2009-July/thread.html
    Thank you.

    I think the thread Nicolas wanted me to see was this one:
    <URL:http://lists.logilab.org/pipermail/python-projects/2009-July/001950.html>.

    --
    \ ?I put contact lenses in my dog's eyes. They had little |
    `\ pictures of cats on them. Then I took one out and he ran around |
    _o__) in circles.? ?Steven Wright |
    Ben Finney
  • Nicolas Chauvat at Jul 15, 2009 at 11:21 am

    On Wed, Jul 15, 2009 at 12:39:48PM +0200, Nicolas Chauvat wrote:
    Here is the ticket:
    https://www.logilab.net/elo/ticket/9634
    Apologies: http://www.logilab.org/ticket/9634

    --
    Nicolas Chauvat

    logilab.fr - services en informatique scientifique et gestion de connaissances
  • Skip at Jul 15, 2009 at 2:22 pm
    Nicolas> Here is the ticket:
    Nicolas> https://www.logilab.net/elo/ticket/9634

    Is it possible to get read-only access to the tracker? It's prompting me
    for a login which I don't have.

    Thx,

    --
    Skip Montanaro - skip at pobox.com - http://www.smontanaro.net/
    when i wake up with a heart rate below 40, i head right for the espresso
    machine. -- chaos @ forums.usms.org
  • Aurélien Campéas at Jul 15, 2009 at 2:33 pm

    On Wed, Jul 15, 2009 at 09:22:11AM -0500, skip at pobox.com wrote:
    Nicolas> Here is the ticket:
    Nicolas> https://www.logilab.net/elo/ticket/9634

    Is it possible to get read-only access to the tracker? It's prompting me
    for a login which I don't have.

    Thx,
    that should be http://www.logilab.org/ticket/9634

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJul 15, '09 at 10:08a
activeJul 15, '09 at 2:33p
posts6
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase