Skip to content

refactor(cli): extract table rendering into cli/rendering.py#228

Merged
ArtVsMark merged 1 commit into
mainfrom
refactor/cli-rendering-extraction
Jul 9, 2026
Merged

refactor(cli): extract table rendering into cli/rendering.py#228
ArtVsMark merged 1 commit into
mainfrom
refactor/cli-rendering-extraction

Conversation

@ArtVsMark

Copy link
Copy Markdown
Owner

Summary

Phase 1 (safe rendering extraction) of #121, Stage 1 of the cli.py decomposition epic (#117). Branched from fresh main (#118#120 already merged).

Moves the pure csv/markdown rendering helpers — _rows_to_csv, _rows_to_markdown, _print_tabular — out of cli/__init__.py into a new leaf module cli/rendering.py, re-exported from the facade for backward compatibility. Same shape as #119's options.py and #120's commands.py extractions.

_print_tabular is already routed through CliContext.print_tabular (added in #120), built fresh per call by _build_cli_context() — mode-handler callers in cli/commands.py are unaffected by this move.

Test fallout (found by running the regression net, not assumed)

_rows_to_csv/_rows_to_markdown are only called internally by _print_tabular (now co-located with them in rendering.py), not referenced anywhere else in cli/__init__.py's body post-move — the same "hidden facade dependency" shape as #119's CONFIG issue. Two tests in test_cli.py (TestFacadeNamespaceContract) patched cli._rows_to_csv/cli._rows_to_markdown expecting the effect to propagate through cli._print_tabular(...); since that internal call now resolves within rendering.py's own namespace, patching the facade-level re-export no longer reaches it. Updated both to patch cli.rendering._rows_to_csv/cli.rendering._rows_to_markdown instead — matching the cli.options.CONFIG pattern from #119.

Every other monkeypatch-based test in the suite needed no changes.

Scope note

This is Phase 1 only. Phase 2 (_LANG/_MESSAGES/_LOCALE_MESSAGES/_t/_interactive_menu/_ask_*/_pick_path_via_dialog) is explicitly out of scope per #121's own non-goals — it needs a separate CliContext-style design pass, same as #120 required.

Test plan

  • pytest tests/ -q — 842 passed, 3 skipped (2 test lines changed in test_cli.py, discovered by actually running the suite before committing)
  • ruff check src tests docs / ruff format --check src tests — clean
  • mypy src/stepik_grader --ignore-missing-imports — clean
  • Manual smoke: stepik-grader --mode 1 --output csv/markdown against a real solution+tests dir
  • Updated docs/architecture.md (module table + DAG) and docs/project-structure.md

🤖 Generated with Claude Code

Phase 1 of issue #121 (Stage 1 of epic #117): moves the pure csv/markdown
rendering helpers (_rows_to_csv, _rows_to_markdown, _print_tabular) out
of cli/__init__.py into a new leaf module cli/rendering.py, re-exported
from the facade for backward compatibility — same shape as #119's
options.py and #120's commands.py extraction.

_print_tabular is already routed through CliContext.print_tabular (added
in #120), built fresh per call by _build_cli_context(), so mode-handler
callers in cli/commands.py are unaffected by this move.

_rows_to_csv/_rows_to_markdown are only called internally by
_print_tabular (now co-located in rendering.py), not referenced anywhere
else in cli/__init__.py's body post-move — same "hidden facade
dependency" shape as #119's CONFIG issue. Two tests in test_cli.py
patched cli._rows_to_csv/cli._rows_to_markdown expecting the effect to
propagate through cli._print_tabular(...); since that internal call now
resolves within rendering.py's own namespace, updated both to patch
cli.rendering._rows_to_csv/cli.rendering._rows_to_markdown instead
(discovered by running TestFacadeNamespaceContract before committing,
not assumed).

Removed now-unused csv/io/Any imports from cli/__init__.py. Updated
docs/architecture.md and docs/project-structure.md for the new leaf
module.

Issue #121 (Phase 1 only — Phase 2 interactive/i18n extraction is a
separate design-first PR per the issue's own non-goals).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ArtVsMark ArtVsMark merged commit 33306df into main Jul 9, 2026
9 checks passed
@ArtVsMark ArtVsMark deleted the refactor/cli-rendering-extraction branch July 9, 2026 08:11
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.

1 participant