Optional dependency management

Avoid including optional or provider-specific dependencies in the main dependency list. Dependencies should only be required if they are essential for core functionality that all users need.

copy reviewer prompt

Prompt

Reviewer Prompt

Avoid including optional or provider-specific dependencies in the main dependency list. Dependencies should only be required if they are essential for core functionality that all users need.

Make dependencies optional when they are:

  • Provider-specific (e.g., groq, mistralai, anthropic clients)
  • Feature-specific (e.g., mcp for specific Python versions)
  • Test-only requirements that not all developers need

Use the optional = true flag and organize them into appropriate extras groups:

[tool.poetry.dependencies]
# Core dependencies only
python = ">=3.9,<3.12"
pydantic = "^2.0"

# Optional dependencies
groq = { version = "^0.4.2", optional = true }
mistralai = { version = "^0.1.3", optional = true }

[tool.poetry.extras]
groq = ["groq"]
mistral = ["mistralai"]

This approach prevents forcing unnecessary installations on users who don’t need specific providers or features, while still making them available for those who do.

Source discussions