Skip to content

Commit 8598235

Browse files
authored
perf: use list comprehension for adding to warnings and enable performance lint rules (#44)
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
1 parent b50349d commit 8598235

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

ruff.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ quote-style = 'single'
66
[lint]
77
ignore = ['E501']
88
select = [
9-
'E', # pycodestyle
10-
'F', # Pyflakes
11-
'UP', # pyupgrade
12-
'B', # flake8-bugbear
13-
'SIM', # flake8-simplify
14-
'I' # isort
9+
'E', # pycodestyle
10+
'F', # Pyflakes
11+
'UP', # pyupgrade
12+
'B', # flake8-bugbear
13+
'SIM', # flake8-simplify
14+
'I', # isort
15+
'PERF' # performance
1516
]
1617

1718
[lint.isort]

scripts/generate_osv_advisories.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,15 @@ def parse_version_constraint(
152152
warnings.append(
153153
'the = operator is not real, and will be treated as an exact version'
154154
)
155-
for component in [
156-
part.first_component or '',
157-
part.second_component or '',
158-
part.third_component or '',
159-
]:
160-
if len(component) > 1 and component.startswith('0'):
161-
warnings.append('components should not be prefixed with leading zeros')
155+
warnings.extend(
156+
'components should not be prefixed with leading zeros'
157+
for component in [
158+
part.first_component or '',
159+
part.second_component or '',
160+
part.third_component or '',
161+
]
162+
if len(component) > 1 and component.startswith('0')
163+
)
162164

163165
# https://getcomposer.org/doc/articles/versions.md#wildcard-version-range-
164166
if parts[0].second_component == '*' or parts[0].third_component == '*':

0 commit comments

Comments
 (0)