Skip to content

Two starter code files on main fail to compile (IndentationError) #146

Description

@ivorb

Two starter .py files in Labfiles/ do not compile as shipped. Learners who follow the exercise and run the file before adding their own code hit an IndentationError immediately.

Found while running py_compile across the whole Labfiles/ tree. Reporting only — not fixed here, since the work that surfaced it (#145) is deliberately additive and doesn't touch these labs.

Failures

Labfiles/05-speech-tool/Python/speech-client/speech-client.py
  IndentationError: expected an indented block after 'else' statement on line 30 (line 35)

Labfiles/06-voice-live/Python/chat-client/chat-client.py
  IndentationError: expected an indented block after 'try' statement on line 72 (line 89)

The other 7 starter files in Labfiles/ compile cleanly.

Cause

Both are the same pattern: a block opener whose body contains only comments, which is not valid Python.

speech-client.py — the else: contains just a comment placeholder:

if prompt == "quit" or len(prompt) == 0:
    break
else:
    # Use the agent to get a response


except Exception as ex:

chat-client.py — the try: contains only the five numbered STEP comments, with the code the learner is meant to add being what would give it a body.

Impact

The exercises tell learners to run the file at an intermediate stage. In 05 the instructions say to review the existing code and add the namespace imports before running; in 06 the scaffolding is presented as runnable. In both cases the file cannot be executed until the learner has added the missing block body, so anyone who runs it early — or who wants to confirm their environment works before editing — gets a syntax error rather than the intended behaviour.

Suggested fix

Give each empty block a body that is valid but obviously a placeholder, so the file compiles and runs while still leaving the exercise intact. Either:

  • restructure so no empty block exists (e.g. in speech-client.py, drop the else: and use continue after break), or
  • add an explicit pass with a comment telling the learner to remove it, e.g. pass # Remove this line once you have added the code for steps 1-5.

Worth adding python -m py_compile over Labfiles/**/*.py to CI to catch this class of problem, since it is invisible to review but immediate for a learner.

Repro

python -m py_compile Labfiles/05-speech-tool/Python/speech-client/speech-client.py
python -m py_compile Labfiles/06-voice-live/Python/chat-client/chat-client.py

Reproduced on Python 3.12 and 3.14.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions