mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-16 23:24:55 -05:00
[PR #1877] [CLOSED] fix(module): syntax errors in student notebook silently pass tito module complete #33430
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1877
Author: @Shashank-Tripathi-07
Created: 6/16/2026
Status: ❌ Closed
Base:
main← Head:fix/module-complete-tests-src-not-notebook📝 Commits (1)
9b6e253catch notebook syntax errors before export so they do not silently pass📊 Changes
1 file changed (+48 additions, -0 deletions)
View changed files
📝
tinytorch/tito/commands/module/workflow.py(+48 -0)📄 Description
Bug report
Reported by @Chufeng-Jiang in discussion #1827.
A student had a syntax error in their Module 01 notebook (missing closing parenthesis in an
isinstancecall). Runningtito module complete 01reported all tests passing. The error only surfaced when Module 02 tests tried to import from the brokentinytorch/core/tensor.pythat the export had written.Root cause
_run_inline_unit_tests()runs the instructor's source file atsrc/01_tensor/01_tensor.py, not the student's notebook atmodules/01_tensor/tensor.ipynb. A syntax error in the student's notebook is invisible to this test phase -- the instructor source always runs clean. The broken notebook then gets exported intotinytorch/core/tensor.pywithout any parse check.Fix
Add
_check_notebook_syntax(): reads the student's notebook, compiles every code cell with Python'scompile(), and returns the firstSyntaxErrorfound with the cell number and line. Called in bothcomplete_moduleand_complete_module_quietimmediately before the export step, so the student sees:instead of a confusing failure in the next module.
Test plan
tito module complete 01reports the error with cell + line number and exits 1tito module complete --all(quiet path) also blocked on syntax errorsCo-authored-by: Chufeng Jiang cjiang@gradcenter.cuny.edu
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.