fix(starter-code): repair expense tracker syntax error#671
fix(starter-code): repair expense tracker syntax error#671DhruvalBhinsara1 wants to merge 2 commits into
Conversation
|
@DhruvalBhinsara1 is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a regression test to ensure Python starter code is syntactically valid, fixes a syntax/indentation issue in the Personal Expense Tracker starter file, and documents the fix in the changelog.
Changes:
- Add a test that compiles
starter_code/*.pyto catch syntax errors early. - Fix
starter_code/expense_tracker.pyso it parses/runs (module docstring + correctmain()invocation indentation). - Update
CHANGELOG.mdto record the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_basic.py | Adds a test that compiles starter-code Python files to prevent shipping syntactically invalid examples. |
| starter_code/expense_tracker.py | Fixes invalid syntax/formatting so the starter script runs correctly. |
| CHANGELOG.md | Records the starter-code compilation fix under “Fixed”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for filename in os.listdir(starter_code_dir): | ||
| if filename.endswith(".py"): | ||
| path = os.path.join(starter_code_dir, filename) | ||
| py_compile.compile(path, doraise=True) |
| for filename in os.listdir(starter_code_dir): | ||
| if filename.endswith(".py"): | ||
| path = os.path.join(starter_code_dir, filename) | ||
| py_compile.compile(path, doraise=True) |
Xenon010101
left a comment
There was a problem hiding this comment.
Addressed both Copilot suggestions:
-
Side-effect-free compile: Changed
py_compile.compile(path, doraise=True)topy_compile.compile(path, doraise=True, cfile=os.devnull)to avoid writing.pycfiles to__pycache__during test runs. -
Recursive directory walk: Replaced
os.listdirwithos.walkso that Python files in subdirectories understarter_code/are also checked for syntactic validity.
def test_python_starter_code_files_compile():
"Python starter files must be syntactically valid for users to run."
starter_code_dir = os.path.join(os.path.dirname(__file__), .., starter_code)
for root, dirs, files in os.walk(starter_code_dir):
for filename in files:
if filename.endswith(.py):
path = os.path.join(root, filename)
py_compile.compile(path, doraise=True, cfile=os.devnull)|
Follow-up status: pushed bf61cc2 to address the review feedback. The starter-code compile test now walks nested Python files and writes bytecode into a temporary directory so test runs do not create persistent .pyc files.\n\nVerification: ......................................... [100%] |
|
@Xenon010101 I believe you haven't assigned me the issue yet, could you please assign it? |
What
Fixes the Personal Expense Tracker starter file so users can run or compile the downloaded starter code without hitting a Python syntax error. The file had a closing module docstring delimiter but no opening delimiter, so its introductory metadata was parsed as executable Python.
How
Added the missing opening triple-quote to make the starter-code metadata a valid module docstring. Added a regression test that compiles every Python file in starter_code with py_compile, and recorded the user-facing fix in CHANGELOG.md per the contribution guide.
Testing
Risks / Notes
No linked issue number yet. Scope is limited to starter-code syntax validity, one regression test, and the changelog entry.