unused variables in list comprehension not reported

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

Nobody has claimed this yet.

Assessment

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

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.

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
Dominant language
Python
Stars
1.5k
Forks
207
Avg merge
4m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from PyCQA/pyflakes

All issues in PyCQA/pyflakes

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.