Workspace/Coding labs
Loading progress

Build a lexical repository symbol index

Intermediate65 min

Input maps virtual Python paths to source text. Parse without importing or executing. List class, function, and async-function definitions that occur directly in module, class, or function bodies, including nested definitions. Return path, dotted lexical name, one-based line, and kind; sort by path, line, name. This deliberately bounded index does not traverse definitions inside conditional/loop blocks or resolve runtime dispatch. Invalid syntax raises ValueError containing the path. All data remains in memory.

Your task

  1. Complete the starter function using the contract above.
  2. Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
  3. Run tests to record your result, then compare with the explained reference solution.

Examples

EXAMPLE 1

Inputa.py contains class Box with method get

OutputBox at line 1; Box.get at line 2

Qualified names preserve lexical ownership.
EXAMPLE 2

InputSource raises at module level then defines safe

OutputIndex includes safe without raising RuntimeError

Parsing does not execute module code.
solution.pyPython 3.12