claude-sonnet-4-20250514· Anthropic LMArena Human Preference 140K
How do I add a package to an optional-dependency with uv add?
- User
How do I add a package to an optional-dependency with uv add?
- Assistant
You can add a package as an optional dependency using the
--optionalflag withuv add. The syntax is:uv add --optional <group-name> <package-name>For example:
uv add --optional dev pytest uv add --optional docs sphinx uv add --optional testing coverageThis will add the package to the specified optional dependency group in your
pyproject.tomlfile. The optional dependencies will appear under[project.optional-dependencies]like:[project.optional-dependencies] dev = ["pytest"] docs = ["sphinx"] testing = ["coverage"]To install optional dependencies later, you can use:
uv sync --extra dev # or uv install --extra devYou can also install multiple optional groups at once:
uv sync --extra dev --extra testing
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.