diff --git a/pyproject.toml b/pyproject.toml index b38a40da33fb..6174f6138447 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ select = [ "B", # flake8-bugbear "FA", # flake8-future-annotations "I", # isort + "PERF", # Perflint "PGH", # pygrep-hooks "RUF", # Ruff-specific and unused-noqa "UP", # pyupgrade @@ -87,11 +88,15 @@ ignore = [ ### # Rules we don't want or don't agree with ### - # Slower and more verbose https://github.com/astral-sh/ruff/issues/7871 - "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` # Used for direct, non-subclass type comparison, for example: `type(val) is str` # see https://github.com/astral-sh/ruff/issues/6465 "E721", # Do not compare types, use `isinstance()` + # Can easily produce false-positives. Worth checking but don't block CI. + # Anyway Python 3.11 introduced "zero cost" exception handling for the non-error path. + # Our tests & scripts run on modern Python versions. + "PERF203", # try-except within a loop incurs performance overhead + # Slower and more verbose https://github.com/astral-sh/ruff/issues/7871 + "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` ### # False-positives, but already checked by type-checkers ### diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 69f5d2b307e3..c0b986d52eea 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -90,14 +90,10 @@ async def get_upstream_repo_url(project: str) -> str | None: # Order the project URLs so that we put the ones # that are most likely to point to the source code first - urls_to_check: list[str] = [] url_names_probably_pointing_to_source = ("Source", "Repository", "Homepage") - for url_name in url_names_probably_pointing_to_source: - if url := project_urls.get(url_name): - urls_to_check.append(url) - urls_to_check.extend( + urls_to_check = [url for url_name in url_names_probably_pointing_to_source if (url := project_urls.get(url_name))] + [ url for url_name, url in project_urls.items() if url_name not in url_names_probably_pointing_to_source - ) + ] for url in urls_to_check: # Remove `www.`; replace `http://` with `https://`