Add hints when `uv init` finds `pyproject.toml` without a project table

Merged
SA
25d ago
+161-7

Summary

uv init reports that a project is already initialized even when pyproject.toml contains only tool configuration. We now explain that the file already exists and suggest how to add project metadata when the file contains only tool settings.

$ uv init
error: Cannot initialize a project in `/work/example` because `pyproject.toml` already exists

hint: To use this directory as a project, declare its name, version, and other metadata in a `[project]` table

For a legacy Poetry project, the hint explains that uv reads project metadata from [project] and suggests converting the [tool.poetry] metadata to that format. Existing projects, workspace roots, and projects explicitly marked unmanaged get the file-exists error alone.