Skip to content

fix: make pythonlings update prefer the current workspace #42

Description

@abhiksark

Motivation

A learner who runs pythonlings update from an initialized workspace reasonably expects that workspace to update. Today the subcommand default targets the home workspace first, which is surprising and can point at a missing directory.

Current evidence

  • pythonlings/cli.py gives update --path a default of default_workspace_root().
  • update_workspace() correctly rejects a target without info.toml, but the CLI target-selection precedence is not aligned with user expectation.

Exact scope

Resolve update targets in this order: explicit update --path, global --root, current working directory when it is a workspace, then the default home workspace. update must never create a missing workspace.

Acceptance checklist

  • pythonlings update --path PATH updates PATH regardless of the working directory or global root.
  • pythonlings --root PATH update updates that root when no --path is supplied.
  • Bare pythonlings update inside a workspace updates the current workspace.
  • Bare pythonlings update outside a workspace falls back to the default home workspace.
  • A missing/non-workspace target produces a friendly non-zero error and does not create directories or curriculum files.
  • Integration tests cover every precedence branch.

Explicit exclusions

Do not change init behavior, add implicit workspace creation to update, modify update copy semantics, or alter the PYTHONLINGS_HOME contract.

Likely files

  • pythonlings/cli.py
  • pythonlings/core/workspace.py
  • tests/integration/test_cli_workspace.py

Verification

python -m pytest tests/integration/test_cli_workspace.py -q
python -m pytest -q

Also exercise each precedence branch in a temporary directory and verify a missing target remains absent.

Sprint coordination

See the sprint Discussion. This issue is unassigned and is not a reservation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliCommand-line interface behaviorbugSomething isn't workingdev sprintPythonlings Community Dev Sprint August 2026good first issueGood for newcomerssize: SSmall, focused contribution

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions