The Python toolchain has been transformed by uv and Ruff — two Rust-powered tools that replace pip, virtualenv, flake8, and black. These exercises cover the new standard toolchain: fast package management, modern linting and formatting, lockfiles, and monorepo workspaces.
0 / 5 completed
1 / 5
At standup, a colleague asks what uv is and how it differs from pip. What is the correct answer?
uv is an all-in-one Python toolchain written in Rust by Astral (the makers of Ruff). It replaces pip, pip-tools, virtualenv, venv, and poetry with a single fast tool. uv resolves dependencies and installs packages 10–100× faster than pip thanks to Rust's parallelism and a built-in cache. It manages virtual environments, lockfiles (uv.lock), and Python versions (uv python install).
2 / 5
During a PR review, a teammate asks what ruff does and whether it replaces both flake8 and black. Which answer is correct?
Ruff is a Rust-powered Python linter and formatter. As a linter it implements rules from flake8 and dozens of its plugins (isort, pep8-naming, pyupgrade, bugbear, etc.) — typically 10–100× faster than running them individually. With ruff format it also replaces Black for code formatting. Both linting and formatting are configured in [tool.ruff] in pyproject.toml, making Ruff a single-tool replacement for the flake8 + isort + black stack.
3 / 5
In a design review, the team discusses lockfiles in uv. A junior engineer asks what uv.lock contains and why it matters. What is correct?
uv.lock is a cross-platform lockfile that records exact resolved versions and content hashes for all direct and transitive dependencies. Unlike requirements.txt (which is platform-specific when generated with hashes), uv.lock is designed to be committed to version control and work correctly across macOS, Linux, and Windows. Running uv sync installs exactly what the lockfile specifies, ensuring reproducible environments across all machines and CI.
4 / 5
An incident report shows two packages in a project requiring conflicting Python versions. A senior engineer asks how pyproject.toml declares Python version constraints in the uv ecosystem. What is correct?
The requires-python field in [project] of pyproject.toml (e.g., requires-python = ">=3.11,<4") declares the Python version constraint. uv honours this during dependency resolution — it will select package versions compatible with the specified Python range and reject the dependency set if no solution exists. uv also reads .python-version for the active interpreter, but requires-python is the authoritative project-level constraint.
5 / 5
During a code review, a senior engineer asks what uv workspaces are and when to use them. What is accurate?
uv workspaces bring monorepo support to Python. You define a workspace root with [tool.uv.workspace] members = ["packages/*"]. uv resolves all workspace members' dependencies together into a single uv.lock, ensuring consistent versions across the monorepo. Member packages can declare { workspace = true } dependencies on sibling packages, and uv sync installs everything correctly. This mirrors the workspace concept from Cargo (Rust) and npm/pnpm workspaces.