Question presented to candidate: "Most new Python projects start with a single pyproject.toml file and a tool like uv. Explain what goes in that file, who reads which part of it, where tomllib fits in, and what actually happens when you run uv add, uv sync and uv run."
What a strong answer should cover:
pyproject.tomlis one TOML file with standard tables:[build-system](PEP 518: how to build the package),[project](PEP 621: name, version,requires-python, dependencies),[dependency-groups](PEP 735: dev-only groups such astestandlint) and a free namespace[tool.NAME]for each tool's own settings.tomllib(standard library since Python 3.11, PEP 680) is the read-only parser:tomllib.load()needs a file opened in binary mode,tomllib.loads()takes a string, and there is nodump().- The uv loop:
uv addeditspyproject.toml, resolves and writes the exact versions touv.lock, and installs into.venv;uv syncmakes.venvmatch the lock;uv runsyncs and then runs the command inside that environment. - Ranges vs pins:
pyproject.tomldeclares the ranges you accept,uv.lockrecords the exact versions and hashes the resolver chose; commit both, never commit.venv. - The build side: a frontend (
uv build,pip) reads[build-system], installs the backend it names (hatchling, setuptools,uv_build) and calls it to make an sdist and a wheel. - A bonus detail: PEP 723 inline script metadata (
# /// script) puts the same TOML inside a single script, anduv run script.pyhonours it.
Code / implementation expected: Optional โ reading a pyproject with tomllib and sketching the four tables is a strong start; no build needed.