refactor(cli): extract table rendering into cli/rendering.py#228
Merged
Conversation
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>
This was referenced Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 1 (safe rendering extraction) of #121, Stage 1 of the
cli.pydecomposition epic (#117). Branched from freshmain(#118–#120 already merged).Moves the pure csv/markdown rendering helpers —
_rows_to_csv,_rows_to_markdown,_print_tabular— out ofcli/__init__.pyinto a new leaf modulecli/rendering.py, re-exported from the facade for backward compatibility. Same shape as #119'soptions.pyand #120'scommands.pyextractions._print_tabularis already routed throughCliContext.print_tabular(added in #120), built fresh per call by_build_cli_context()— mode-handler callers incli/commands.pyare unaffected by this move.Test fallout (found by running the regression net, not assumed)
_rows_to_csv/_rows_to_markdownare only called internally by_print_tabular(now co-located with them inrendering.py), not referenced anywhere else incli/__init__.py's body post-move — the same "hidden facade dependency" shape as #119'sCONFIGissue. Two tests intest_cli.py(TestFacadeNamespaceContract) patchedcli._rows_to_csv/cli._rows_to_markdownexpecting the effect to propagate throughcli._print_tabular(...); since that internal call now resolves withinrendering.py's own namespace, patching the facade-level re-export no longer reaches it. Updated both to patchcli.rendering._rows_to_csv/cli.rendering._rows_to_markdowninstead — matching thecli.options.CONFIGpattern 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 separateCliContext-style design pass, same as #120 required.Test plan
pytest tests/ -q— 842 passed, 3 skipped (2 test lines changed intest_cli.py, discovered by actually running the suite before committing)ruff check src tests docs/ruff format --check src tests— cleanmypy src/stepik_grader --ignore-missing-imports— cleanstepik-grader --mode 1 --output csv/markdownagainst a real solution+tests dirdocs/architecture.md(module table + DAG) anddocs/project-structure.md🤖 Generated with Claude Code