PyCQA / PyCQA/pyflakes

unused variables in list comprehension not reported

Open
#593 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
190
Avg merge
8m
Merged PRs (30d)
13

Description

Test code:

def t(items):
  return ['{x}' for x in items]

There is a missing f prefix which makes the local x variable unused, but pyflakes doesn't notice this.

$ pyflakes --version
2.2.0 Python 3.8.6 on Linux

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Python list-comprehension example and inspect pyflakes' unused-variable analysis for comprehension targets. Add regression coverage showing that x is reported when the string lacks the f prefix, then run the relevant test suite and confirm the diagnostic appears.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.