Data Models

All models are frozen dataclasses importable from depwhy:

python
from depwhy import ConflictReport, Conflict, FixCandidate, Constraint

ConflictReport

The top-level result returned by analyze().

| Field | Type | Description | |-------|------|-------------| | has_conflicts | bool | True if at least one hard conflict was detected | | conflicts | list[Conflict] | All detected hard conflicts | | warnings | list[str] | Soft warnings (narrowed-but-valid ranges) | | analyzed_packages | int | Total number of packages examined |

python
report = depwhy.analyze("requirements.txt")
print(f"Analyzed {report.analyzed_packages} packages")
print(f"Found {len(report.conflicts)} conflicts")
print(f"Warnings: {report.warnings}")

Conflict

A single unresolvable dependency conflict.

| Field | Type | Description | |-------|------|-------------| | package | str | The package that cannot be resolved (e.g., "urllib3") | | problem | str | Plain-English one-liner describing the conflict | | constraints | list[Constraint] | All version constraints causing the conflict | | solution | FixCandidate | The top recommended fix | | alternative | FixCandidate \| None | Second-best fix (may be None) |


FixCandidate

A candidate fix for a conflict.

| Field | Type | Description | |-------|------|-------------| | description | str | Human-readable fix description | | pip_command | str | Copy-pasteable pip install command | | is_alternative | bool | False for top fix, True for fallback |


Constraint

A single version constraint imposed by a dependent.

| Field | Type | Description | |-------|------|-------------| | package | str | Package being constrained (e.g., "urllib3") | | specifier | str | PEP 440 version specifier (e.g., ">=1.21.1,<1.27") | | required_by | str | The dependent imposing this constraint | | chain | list[str] | Full dependency chain leading to this constraint |

Inspecting constraints

python
for conflict in report.conflicts:
  print(f"\n{conflict.package}:")
  for c in conflict.constraints:
      print(f"  {c.required_by} requires {c.package}{c.specifier}")
      if c.chain:
          print(f"    Chain: {' → '.join(c.chain)}")