setuptools icon indicating copy to clipboard operation
setuptools copied to clipboard

Enforce ruff/flake8-comprehensions rules (C4)

Open DimitriPapadopoulos opened this issue 1 year ago • 10 comments

Summary of changes

Pull Request Checklist

DimitriPapadopoulos avatar Jan 01 '25 12:01 DimitriPapadopoulos

⚠️ The sha of the head commit of this PR conflicts with #4386. Mergify cannot evaluate rules on this PR. ⚠️

mergify[bot] avatar Jan 01 '25 12:01 mergify[bot]

⚠️ The sha of the head commit of this PR conflicts with #4386. Mergify cannot evaluate rules on this PR. ⚠️

mergify[bot] avatar Jan 05 '25 15:01 mergify[bot]

I think you'll want to enable allow-dict-calls-with-keyword-arguments I'd have to find it back, but I believe that's a stylistic decision @jaraco has previously weighed in.

Avasam avatar Mar 11 '25 18:03 Avasam

After adding allow-dict-calls-with-keyword-arguments, most occurrences of C408 have disappeared. A few instances of dict(){} have been left behind. Should I discard them as well and disable C408?

DimitriPapadopoulos avatar Mar 12 '25 18:03 DimitriPapadopoulos

I personally think those make sense, it's mainly changing generators of tuples into dict comprehensions.

Avasam avatar Mar 12 '25 23:03 Avasam

Rebased.

DimitriPapadopoulos avatar May 23 '25 08:05 DimitriPapadopoulos

  • The Python 3.14 CI errors might be related to https://github.com/python/cpython/issues/133653.
  • Not sure about the PyPy 3.10 CI error, but it seems unrelated to this PR as well.

DimitriPapadopoulos avatar May 23 '25 08:05 DimitriPapadopoulos

I'm not sure your rebase is correct. I see refurb related changes and the change dict(foo=bar) --> {"foo": bar} which was previously mentioned as unwanted.

PyPy tests have also been flaky: https://github.com/pypa/setuptools/issues/4940

Avasam avatar May 23 '25 14:05 Avasam

I had to rerun C401 and C408 because rebasing was impossible. I guess I somehow got the options wrong. Will try again.

DimitriPapadopoulos avatar May 23 '25 14:05 DimitriPapadopoulos

Reapplied C408 after making sure allow-dict-calls-with-keyword-arguments is true.

DimitriPapadopoulos avatar May 23 '25 15:05 DimitriPapadopoulos