fix: Sprint 1+2 — критические исправления и рефакторинг (аудит июнь 2026)#4
Merged
Conversation
…name, добавить __future__ annotations
This was referenced Jun 25, 2026
ArtVsMark
added a commit
that referenced
this pull request
Jul 2, 2026
…finding #4) grader.py (1460 lines) violated SRP by combining test-case loading, solution execution, table/rich output, and CLI menu logic in one file. Splits it into three modules per Sprint 7: - grader_core.py: load_test_cases, run_mode detection, wrapper codegen, run_single_test/run_tests/run_benchmark/run_microbench_mode. - reporter.py: the _console/_RICH rich-optional singleton, format_*/ print_* table functions, _cprint, _print_case_verbose. - cli.py: _interactive_menu, load-profile prompts, new main() entry point. grader.py itself becomes an 8-statement backward-compatibility facade: `from X import *` plus explicit re-exports of every private name and non-__all__ public name (run_microbench, apply_relative_ranking) the test suite references directly as grader.X, since `import *` skips underscore-prefixed names. Several tests patched grader._RICH/_console/Table/Text/run_tests/ run_single_test/run_microbench expecting to affect functions that now live in reporter.py/grader_core.py/cli.py -- those functions read their own module's globals at call time, not grader.py's re-exported copy, so the old patch targets silently stopped having any effect (two cases actually failed with AssertionError/KeyError; others degraded into testing the wrong branch without erroring). Updated patch targets in test_grader_coverage_gap.py, test_menu_modes.py, test_grader_extra.py, and test_formatters.py to point at the module that actually owns each name. Added a ruff per-file-ignore for grader.py (F401/F403/F405/I001) since every import in the facade is an intentional re-export. 465 passed (3 skipped), 88.97% coverage; ruff check/format clean; `echo 0 | python grader.py` smoke-tested end-to-end. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
🔧 Аудит июнь 2026 — Sprint 1 (критические) + Sprint 2 (рефакторинг)
Что исправлено
🔴 Sprint 1 — Critical Fixes
pyproject.toml/requirements.txtchardet, убраны дублиat_first.py/api/stepics/1→/api/steps/{step_id}; убран_ = step_idmicrobench_runner.py[source_code]→[""]— пустой stdin вместо кода в качестве вводаat_first.pytest.pyavg_time = total_timeпри FAILED →avg_time = 0.0(делитель был 0)diagnostik_stepik.pyOAUTH_TIMEOUT_SECONDS = 120,server.timeout,join(timeout=120),TimeoutErrorвместоRuntimeError🟡 Sprint 2 — Рефакторинг
test.pySIMILAR_THRESHOLD_PERCENT = 5.0; константа импортируется изmicrobench_runner— единый источник истиныmicrobench_runner.pyfunc_name: str = "<exec>"из@dataclass MicrobenchResulttest.pyfrom __future__ import annotationsуже присутствовал ✔Проверка
python -m py_compile at_first.py diagnostik_stepik.py test.py microbench_runner.py executor.py ruff check .Что осталось (Sprint 3 — отдельная ветка)
tests/с unit-тестами (pytest)python_requires = ">=3.10"вpyproject.tomlstepik_client.py