Skip to content

Enforce ruff/flake8-comprehensions rules (C4)#407

Merged
astanin merged 5 commits into
astanin:masterfrom
DimitriPapadopoulos:C4
Mar 5, 2026
Merged

Enforce ruff/flake8-comprehensions rules (C4)#407
astanin merged 5 commits into
astanin:masterfrom
DimitriPapadopoulos:C4

Conversation

@DimitriPapadopoulos
Copy link
Copy Markdown
Contributor

No description provided.

@codecov-commenter
Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Comment thread test/test_regression.py
assert_equal(expected, result)

lod = [{p: i for p in range(5)} for i in range(5)]
lod = [dict.fromkeys(range(5), i) for i in range(5)]
Copy link
Copy Markdown
Contributor Author

@DimitriPapadopoulos DimitriPapadopoulos Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is more readable, but then that's the exact use case for dict.fromkeys(), added in Python 2.3.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never noticed it exists.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Ruff made me discover it 😄

@DimitriPapadopoulos DimitriPapadopoulos force-pushed the C4 branch 3 times, most recently from 6e44670 to 0162bbc Compare March 5, 2026 13:32
@DimitriPapadopoulos
Copy link
Copy Markdown
Contributor Author

I don't understand the tox error:

  File "/opt/hostedtoolcache/Python/3.13.12/x64/lib/python3.13/site-packages/tox/config/sets.py", line 140, in _on_duplicate_conf
    raise ValueError(msg)
ValueError: duplicate configuration definition for .pkg:
has: ConfigConstantDefinition(keys=['env_name', 'envname'], desc=the name of the tox environment, value=.pkg)
new: ConfigConstantDefinition(keys=['env_name', 'envname'], desc=the name of the tox environment, value=.pkg)

Nothing appears to have changed 🤔

Unnecessary list comprehension (rewrite using `list()`)
Unnecessary `map()` usage (rewrite using a list comprehension)
Unnecessary list comprehension
Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
@DimitriPapadopoulos
Copy link
Copy Markdown
Contributor Author

DimitriPapadopoulos commented Mar 5, 2026

By the way, the error predates the setuptools → flit migration.

@DimitriPapadopoulos
Copy link
Copy Markdown
Contributor Author

Ouch, that was the result of a missing quote " in pyproject.toml (merging error during rebase).

@astanin astanin merged commit 527d31e into astanin:master Mar 5, 2026
19 checks passed
@astanin
Copy link
Copy Markdown
Owner

astanin commented Mar 5, 2026

Thank you.

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

Successfully merging this pull request may close these issues.

3 participants