MicrosoftLearning / MicrosoftLearning/mslearn-ai-language

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

Open Beginner friendly
#146 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
273
Forks
544
Avg merge
2m
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Labfiles/05-speech-tool/Python/speech-client/speech-client.py and Labfiles/06-voice-live/Python/chat-client/chat-client.py, focusing on the empty else and try blocks identified in the report. Run the two listed python -m py_compile commands after making each block valid while preserving the exercise scaffolding; done means both files compile without IndentationError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.