Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F841 is triggered by unused variables in tuple unpacking from with statements (#890 regression) #11797

Open
andykais opened this issue Jun 7, 2024 · 0 comments

Comments

@andykais
Copy link

andykais commented Jun 7, 2024

An older issue (#890) called out this behavior as fixed, but it appears to be reintroduced in ruff 0.4.7. The following code snippet gives an error on F841:

def paginate():
  pass

def foo():
  total, results = paginate()
  return results

ruff check ruff_test.py

ruff_test.py:5:3: F841 Local variable `total` is assigned to but never used
  |
4 | def foo():
5 |   total, results = paginate()
  |   ^^^^^ F841
6 |   return results
  |
  = help: Remove assignment to unused variable `total`

Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).

The error goes away by prefixing total with _. Is this now the required recommendation for unused tuple unpacking args? I noticed that for loops do not exhibit this error. E.g.

  for i in range(100):
    print('foo')

this does not report an error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant