From b6e52c84c50dead8da289805ee6f31ab90e7183e Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 22 May 2025 12:00:17 +1200 Subject: [PATCH 1/3] perf: use list comprehension --- scripts/generate_osv_advisories.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/generate_osv_advisories.py b/scripts/generate_osv_advisories.py index 8fdda1a2..613aaaa5 100755 --- a/scripts/generate_osv_advisories.py +++ b/scripts/generate_osv_advisories.py @@ -152,13 +152,17 @@ def parse_version_constraint( warnings.append( 'the = operator is not real, and will be treated as an exact version' ) - for component in [ - part.first_component or '', - part.second_component or '', - part.third_component or '', - ]: - if len(component) > 1 and component.startswith('0'): - warnings.append('components should not be prefixed with leading zeros') + warnings.extend( + [ + 'components should not be prefixed with leading zeros' + for component in [ + part.first_component or '', + part.second_component or '', + part.third_component or '', + ] + if len(component) > 1 and component.startswith('0') + ] + ) # https://getcomposer.org/doc/articles/versions.md#wildcard-version-range- if parts[0].second_component == '*' or parts[0].third_component == '*': From 1816b1be259f51289cfa419add5a9d2b6a1b9dc1 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 22 May 2025 12:00:33 +1200 Subject: [PATCH 2/3] chore: enable performance linter --- ruff.toml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ruff.toml b/ruff.toml index b89efdb2..959b75ad 100644 --- a/ruff.toml +++ b/ruff.toml @@ -6,12 +6,13 @@ quote-style = 'single' [lint] ignore = ['E501'] select = [ - 'E', # pycodestyle - 'F', # Pyflakes - 'UP', # pyupgrade - 'B', # flake8-bugbear - 'SIM', # flake8-simplify - 'I' # isort + 'E', # pycodestyle + 'F', # Pyflakes + 'UP', # pyupgrade + 'B', # flake8-bugbear + 'SIM', # flake8-simplify + 'I', # isort + 'PERF' # performance ] [lint.isort] From c53acc3e2e9e0a25bf1d0e2651f3d138c5605ad2 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 22 May 2025 12:07:58 +1200 Subject: [PATCH 3/3] refactor: remove unneeded list --- scripts/generate_osv_advisories.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/generate_osv_advisories.py b/scripts/generate_osv_advisories.py index 613aaaa5..23b080f9 100755 --- a/scripts/generate_osv_advisories.py +++ b/scripts/generate_osv_advisories.py @@ -153,15 +153,13 @@ def parse_version_constraint( 'the = operator is not real, and will be treated as an exact version' ) warnings.extend( - [ - 'components should not be prefixed with leading zeros' - for component in [ - part.first_component or '', - part.second_component or '', - part.third_component or '', - ] - if len(component) > 1 and component.startswith('0') + 'components should not be prefixed with leading zeros' + for component in [ + part.first_component or '', + part.second_component or '', + part.third_component or '', ] + if len(component) > 1 and component.startswith('0') ) # https://getcomposer.org/doc/articles/versions.md#wildcard-version-range-