Skip to content

Ruff PERF203: try/except-in-loop findings (review fault-isolation semantics first) #495

Closed

Description

@squid-protocol

Objective

Part of the ruff lint baseline cleanup (PERF203 -- try/except inside a loop body). Chunked out of the larger sub-issue this replaces, so it's a manageable, self-contained pickup.

Findings

  • gitgalaxy/cobol_to_java_controller.py:221 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/cobol_to_java_controller.py:303 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/metrics/chronometer.py:424 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/metrics/statistical_auditor.py:312 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/security/security_auditor.py:424 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/tools/cobol_to_cobol/cobol_compiler_forge.py:207 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/tools/network_auditing/full_api_network_map.py:333 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/tools/network_auditing/full_api_network_map.py:351 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/tools/supply_chain_security/binary_anomaly_detector.py:204 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/tools/supply_chain_security/vault_sentinel.py:145 (PERF203) -- try-except within a loop incurs performance overhead
  • gitgalaxy/tools/terabyte_log_scanning/terabyte_log_scanner.py:153 (PERF203) -- try-except within a loop incurs performance overhead

Approach

Moving the try outside the loop can change error-isolation semantics -- one bad iteration currently doesn't kill the rest of the batch in most of these call sites (per-file/per-item fault isolation is a deliberate pattern elsewhere in this codebase). Confirm each loop body's fault-isolation intent before restructuring; some of these may be correctly left as-is with a # noqa: PERF203 and a one-line comment explaining why, rather than mechanically hoisted.

Fix in a small PR, removing resolved entries from tests/ruff_audit_baseline.json (see tests/ruff_audit.py's module docstring for the regen command).

Parent: #469

Activity

  1. added
    good first issue
    python
    refactor
    priority: low
    on Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuepriority: lowpythonrefactor

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions