Skip to content

refactor(python): simplify control flow - #19115

Merged
Tobias Brick (tobiasb-ms) merged 2 commits into
microsoft:4.0from
tobiasb-ms:tobiasb-ms/ruff-simplify-control-flow
Oct 8, 2026
Merged

Tobias Brick (tobiasb-ms) merged 2 commits into
microsoft:4.0from
tobiasb-ms:tobiasb-ms/ruff-simplify-control-flow

Conversation

@tobiasb-ms

Copy link
Copy Markdown
Contributor

Summary

Simplify equivalent control-flow patterns across the image-test plugin,
rendered-spec reporting, and repository metadata tooling.

Remove the baseline suppressions for SIM102, SIM108, and SIM113 after
resolving every existing finding. The cleanup and enforcement changes remain
split into separate commits.

This continues the focused Ruff rollout following #19114.

Validation

  • pre-commit run --all-files
  • rendered-spec tests: 11 passed
  • image test suite: all 73 tests collected through the modified pytest plugin
  • changed-file compile and startup smoke checks

Collapse nested conditions, use existing iteration state directly, and replace equivalent branches while preserving behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the SIM102, SIM108, and SIM113 debt suppressions after resolving every existing finding.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 20:28
@tobiasb-ms
Tobias Brick (tobiasb-ms) requested a review from a team as a code owner October 8, 2026 20:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The refactors preserve existing behavior, and the newly enabled Ruff rules were comprehensively validated.

0 open findings

What changed in this PR

Simplifies equivalent Python control-flow patterns and enables additional Ruff checks.

Changes:

  • Replaces nested conditionals and manual counters with simplified constructs.
  • Removes global suppressions for SIM102, SIM108, and SIM113.
File Description
scripts/​repo/​synthesize-repodata.py Simplifies routing selection with a conditional expression.
scripts/​ci/​render-specs-check/​post_render_comment.py Uses enumerate for inline-diff counting.
ruff.toml Enables three Ruff simplification rules.
base/​images/​tests/​utils/​pytest_plugin.py Combines nested image-reference checks.
base/​images/​tests/​cases/​static/​test_efi.py Flattens nested EFI-entry conditions.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tobiasb-ms

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.

@tobiasb-ms
Tobias Brick (tobiasb-ms) merged commit c9de561 into microsoft:4.0 Oct 8, 2026
14 checks passed
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.

3 participants