GithubHelp home page GithubHelp logo

Comments (7)

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by icordasc (@sigmavirus24?) on Launchpad:


I couldn't reproduce this with the attached file.

from pyflakes.

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by bistromathic1 on Launchpad:


This problem seems to occur when a dummy variable name in a generator expression, a dict comprehension, or a set comprehension is then reused in a list comprehension, for example:

a = [1, 2, 3, 4, 5, 6]

b = (i + 1 for i in a)
c = [i + 2 for i in b]

print(c)

The pyflakes output is:

test-1.py:4: list comprehension redefines 'i' from line 3

I only tried this in python 3.2.

from pyflakes.

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by florent.x (@florentx?) on Launchpad:


actually, this should not report redefinition of variable for:

  • generator expressions
  • dict comprehensions
  • set comprehensions

Only the list comprehension leaks its variable, and only with Python 2.x.
(Though we'll keep reporting the warning for 3.x as well)

from pyflakes.

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by florent.x (@florentx?) on Launchpad:


This should fix it.

https://code.launchpad.net/~pyflakes-dev/pyflakes/1112067-comprehension-scope/+merge/147264

from pyflakes.

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by danken on Launchpad:


I'm not sure it's the very same bug, but pylakes 0.6.1 (python 2.7.3) considers the following as having a redefinition of x:

if False:
x = 1
else:
[x for x in [1]]

from pyflakes.

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by florent.x (@florentx?) on Launchpad:


I'm not sure it's the very same bug, but pylakes 0.6.1 (python 2.7.3) considers the following as having a redefinition of x:

if False:
x = 1
else:
[x for x in [1]]

this last one is a different bug, it should be reported separately.

from pyflakes.

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by florent.x (@florentx?) on Launchpad:


The fix for this second bug was added to the same branch:
https://code.launchpad.net/~pyflakes-dev/pyflakes/1112067-comprehension-scope/+merge/147264

from pyflakes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.