Skip to content

chore: enable ruff flake8-comprehensions (C4) rules#5107

Open
yosofbadr wants to merge 2 commits intoopen-telemetry:mainfrom
yosofbadr:chore/enable-ruff-rules
Open

chore: enable ruff flake8-comprehensions (C4) rules#5107
yosofbadr wants to merge 2 commits intoopen-telemetry:mainfrom
yosofbadr:chore/enable-ruff-rules

Conversation

@yosofbadr
Copy link
Copy Markdown

@yosofbadr yosofbadr commented Apr 15, 2026

Description

Enable the C4 (flake8-comprehensions) rule set in ruff and fix all existing violations.

Fixes addressed:

Rule Description File
C401 Use set comprehension instead of set(generator) codegen/.../generator.py
C408 Use tuple literal () instead of tuple() exporter/.../exporter.py
C417 Use generator expression instead of map(lambda) opentelemetry-sdk/.../util/__init__.py
C417 Use list comprehension instead of map(lambda) shim/.../testcase.py

Addresses #4227

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Ran ruff check . with the new C4 rule enabled - all checks pass
  • Changes are mechanical rewrites that preserve identical runtime behavior

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 15, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@yosofbadr yosofbadr marked this pull request as ready for review April 16, 2026 04:38
@yosofbadr yosofbadr requested a review from a team as a code owner April 16, 2026 04:38
@tammy-baylis-swi
Copy link
Copy Markdown
Contributor

Overall lgtm; please add a Changelog entry since this touches some code.

Enable the C4 (flake8-comprehensions) rule set in ruff and fix all
existing violations:

- C401: Use set comprehension instead of set(generator)
- C408: Use tuple literal () instead of tuple()
- C417: Use generator expression / list comprehension instead of map(lambda)

Addresses open-telemetry#4227

Assisted-by: Claude Opus 4.6
Signed-off-by: Yosof Badr <23705518+YosofBadr@users.noreply.github.com>
@yosofbadr yosofbadr force-pushed the chore/enable-ruff-rules branch from 39227ca to e0add0c Compare April 21, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants