Skip to content

feat: add pythonlings doctor diagnostics - #67

Open
Huoyanlifusu wants to merge 2 commits into
abhiksark:devfrom
Huoyanlifusu:feature/doctor-diagnostics
Open

feat: add pythonlings doctor diagnostics#67
Huoyanlifusu wants to merge 2 commits into
abhiksark:devfrom
Huoyanlifusu:feature/doctor-diagnostics

Conversation

@Huoyanlifusu

Copy link
Copy Markdown
Contributor

Closes #46

Summary

Adds pythonlings [--root PATH] doctor, a read-only diagnostic command that reports:

  • Python runtime and installed package version
  • workspace structure and manifest validity
  • solution availability
  • progress-state readability
  • reset-snapshot coverage
  • bundled-docs coverage

Warnings never fail the command; required failures exit 1. The command never
creates, repairs, renames, or otherwise modifies workspace files — it uses its own
non-mutating inspection path (no reuse of the mutating state loader) and mirrors
core/reset.py's snapshot-path logic only.

Behavior

  • Discoverable in pythonlings --help and respects global --root (explicit
    --root wins over the current workspace).
  • Resolution failures (symlink loops, unknown ~user) are reported as a friendly
    [FAIL] Workspace: line with no traceback.
  • Malformed manifests (wrong field types, missing files, directories where files
    belong) are caught and reported as [FAIL] Manifest: with no traceback.
  • Corrupt or unreadable state is a warning and is never touched (no .bak, no repair).
  • Symlink-loop detection uses os.stat (errno.ELOOP) so it is consistent across
    Python versions (Path.resolve() stopped raising on loops in Python 3.13).

Tests

  • python -m pytest tests/unit/test_doctor.py tests/integration/test_cli_doctor.py -q
    • 18 passed
  • python -m pytest -q
    • 203 passed
  • pythonlings --root tests/fixtures/passing_curriculum verify
    • passed
  • pythonlings --root tests/fixtures/passing_curriculum doctor
    • 8 checks, 3 warning(s), 0 failure(s) (fixture lacks solutions/snapshots/docs)
  • Read-only check on a freshly inited workspace (1172 files): SHA-256 hashes
    identical before and after doctor

Representative output (healthy workspace)

Pythonlings doctor
Workspace: <root>

[OK] Python runtime: Python 3.11.15
[OK] Pythonlings version: pythonlings 0.4.1
[OK] Workspace: <root>
[OK] Manifest: 292 exercises across 31 topics
[OK] Solutions: 292/292 available
[OK] Progress state: no progress file yet
[OK] Reset snapshots: 292/292 available
[OK] Bundled docs: 31/31 topics available

Summary: 8 checks, 0 warning(s), 0 failure(s)

Reinhardt Zhang added 2 commits August 17, 2026 08:54
Add a `pythonlings doctor` subcommand that inspects the runtime,
package version, workspace structure, manifest, solutions, state,
reset snapshots, and bundled docs without mutating any files.
Warnings do not fail the command; required failures exit 1.
Path.resolve() no longer raises on symlink loops in Python 3.13, so
detect the loop explicitly with os.stat (errno.ELOOP) instead of
relying on resolve()/exists() behavior that differs across versions.
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f9cbf2b4-d993-4375-86c5-1b5ebce13344

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant