Skip to content

refactor: tighten stage 1 ruff thresholds#1113

Open
zeel2104 wants to merge 5 commits intomicrosoft:mainfrom
zeel2104:strangler-stage-1-ruff-thresholds
Open

refactor: tighten stage 1 ruff thresholds#1113
zeel2104 wants to merge 5 commits intomicrosoft:mainfrom
zeel2104:strangler-stage-1-ruff-thresholds

Conversation

@zeel2104
Copy link
Copy Markdown
Contributor

@zeel2104 zeel2104 commented May 3, 2026

Description

Tightens the Stage 1 Ruff complexity thresholds for the strangler-fig refactor work and trims the main outliers blocking those guardrails.

Changes include:

  • Reduced complexity and branching in MCPIntegrator.install by extracting runtime selection, registry install, self-defined install, and summary helpers.
  • Reduced return pressure in marketplace publishing by splitting single-target processing into smaller checkout/load/guard/write/commit/push helpers.
  • Reduced install wrapper argument count with a frozen options dataclass.
  • Added targeted waivers for existing legacy helper functions where broader extraction is better suited to follow-up stages.
  • Updated Ruff thresholds in pyproject.toml to the Stage 1 targets.

Fixes #1077

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Validation run:

uv run --python 3.13 --extra dev ruff check src/ tests/


## Results

All checks passed

Copilot AI review requested due to automatic review settings May 3, 2026 00:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors several high-complexity/return-pressure hotspots to meet Stage 1 Ruff thresholds, and updates the Ruff thresholds in pyproject.toml accordingly (per #1077).

Changes:

  • Updates Ruff complexity/args/returns thresholds to Stage 1 targets in pyproject.toml.
  • Extracts helper functions to reduce complexity/returns in MCP installation and marketplace publishing flows.
  • Reduces install wrapper argument pressure by introducing an options dataclass and **kwargs validation.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/apm_cli/policy/policy_checks.py Refactors check execution into iterable loops for dependency + MCP policy checks.
src/apm_cli/marketplace/semver.py Simplifies comparison operator handling via a small operator/comparator table.
src/apm_cli/marketplace/publisher.py Splits per-target publish processing into smaller checkout/load/guard/write/commit/push helpers.
src/apm_cli/integration/mcp_integrator.py Extracts runtime selection, dependency splitting, registry/self-defined install, and summary helpers to reduce install complexity.
src/apm_cli/install/validation.py Adds targeted Ruff waivers for legacy complexity outliers.
src/apm_cli/install/services.py Adds targeted Ruff waiver for max-args on a legacy entry point.
src/apm_cli/install/mcp/conflicts.py Adds targeted Ruff waiver for max-args on a legacy validator.
src/apm_cli/install/mcp/command.py Adds targeted Ruff waiver for max-args on a legacy command wrapper.
src/apm_cli/commands/install.py Introduces frozen options dataclass for _install_apm_dependencies and switches wrapper to **kwargs.
pyproject.toml Tightens Ruff thresholds to Stage 1 values (statements/branches/complexity/args/returns).

Comment thread src/apm_cli/policy/policy_checks.py
Comment thread src/apm_cli/integration/mcp_integrator.py
Comment thread src/apm_cli/integration/mcp_integrator.py
Comment thread src/apm_cli/commands/install.py Outdated
@sergio-sisternes-epam
Copy link
Copy Markdown
Collaborator

Hey @zeel2104 -- welcome and thanks for picking up #1077! The strangler-fig direction here is exactly right, and the threshold reductions are meaningful. Great first contribution.

I can see that commit 71784c5 already addresses all four Copilot review comments (lazy lambdas for fail_fast, Protocol-based type hints, Optional annotations on the dataclass). Nice work -- please reply to each Copilot comment thread explaining the fix and resolve the conversations so the review state is clean.

There are still a few CI blockers that need addressing before we can proceed:

CI failures

  1. Ruff format -- mcp_integrator.py and publisher.py need reformatting. Running uv run --extra dev ruff format src/ tests/ should sort this out.
  2. test_install_py_under_legacy_budget -- commands/install.py is now at ~1840 LOC, which exceeds the 1825-line architecture guardrail. This needs a proper extraction into apm_cli/install/ rather than cosmetic trimming (the test message itself points to the python-architecture skill for guidance).
  3. test_no_stored_configs_preserves_existing_behavior -- the MCP integrator refactor appears to have moved or renamed the _rich_success call path, so the mock target in this test no longer matches. Please check the new call chain and update the mock accordingly.

Rebase

The branch currently has merge conflicts with main. Please rebase onto the latest main so we get a clean diff.


Once these are resolved, we will trigger a full panel evaluation of the PR. Happy to help if you have any questions -- just ping here. Thanks again!

@zeel2104
Copy link
Copy Markdown
Contributor Author

zeel2104 commented May 4, 2026

Thanks for the follow-up. I addressed the remaining Ruff/CI and merge-conflict issues.

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.

Strangler Stage 1: tame the worst outliers

3 participants