Skip to content

perf: use list comprehension for adding to warnings and enable performance lint rules#44

Merged
G-Rath merged 3 commits into
mainfrom
lint/perf
May 22, 2025
Merged

perf: use list comprehension for adding to warnings and enable performance lint rules#44
G-Rath merged 3 commits into
mainfrom
lint/perf

Conversation

@G-Rath

@G-Rath G-Rath commented May 22, 2025

Copy link
Copy Markdown
Collaborator

Technically this is faster than how we were doing it previously, though in practice it won't be measurable but I think it's still nice to do along with enabling the performance lint rules rather than doing an inline disable

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

Optimizes warning collection by switching from a loop to a list comprehension and turns on performance linting in Ruff.

  • Replaces manual for+append with a single warnings.extend([...]) comprehension.
  • Updates ruff.toml to enable the PERF lint rules and add a trailing comma to the I entry.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/generate_osv_advisories.py Switch to list comprehension for leading-zero warnings
ruff.toml Add 'I', formatting and enable the PERF performance rules
Comments suppressed due to low confidence (1)

scripts/generate_osv_advisories.py:152

  • Add or update a test case that includes version components with leading zeros to verify this new list comprehension path triggers as expected.
for component in [

Comment thread scripts/generate_osv_advisories.py Outdated
Comment thread scripts/generate_osv_advisories.py Outdated
warnings.append('components should not be prefixed with leading zeros')
warnings.extend(
[
'components should not be prefixed with leading zeros'

Copilot AI May 22, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Including the actual component value in the warning (for example, f"component '{component}' should not be prefixed with leading zeros") would provide more context when debugging.

Suggested change
'components should not be prefixed with leading zeros'
f"component '{component}' should not be prefixed with leading zeros"

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it should be very obvious what component has the leading zeros when reviewing the advisory with the warning, so I don't think this is needed

@G-Rath G-Rath merged commit 8598235 into main May 22, 2025
5 checks passed
@G-Rath G-Rath deleted the lint/perf branch May 22, 2025 21:04
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.

4 participants