Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dev = [
"pytest-cov>=4.1.0,<5.0.0",
"pytest-xdist>=3.0.0,<4.0.0",
"ruff>=0.4.4,<0.5.0",
"tomli>=2.2.1,<3.0.0",
]
docs = [
"sphinx>=5.0.0,<6.0.0",
Expand Down Expand Up @@ -125,7 +126,7 @@ all = [
"sphinx-autodoc-typehints>=1.12.0,<2.0.0",

# litellm
"litellm>=1.72.6,<1.73.0",
"litellm>=1.73.1,<2.0.0",

# llama
"llama-api-client>=0.1.0,<1.0.0",
Expand Down Expand Up @@ -159,7 +160,7 @@ features = ["anthropic", "litellm", "llamaapi", "ollama", "openai", "otel", "mis
dependencies = [
"mypy>=1.15.0,<2.0.0",
"ruff>=0.11.6,<0.12.0",
"strands-agents @ {root:uri}"
"strands-agents @ {root:uri}",
]

[tool.hatch.envs.hatch-static-analysis.scripts]
Expand All @@ -185,6 +186,7 @@ extra-dependencies = [
"pytest-asyncio>=0.26.0,<0.27.0",
"pytest-cov>=4.1.0,<5.0.0",
"pytest-xdist>=3.0.0,<4.0.0",
"tomli>=2.2.1,<3.0.0",
]
extra-args = [
"-n",
Expand Down
48 changes: 48 additions & 0 deletions tests/strands/test_pyproject.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Tests for project configuration consistency."""

from pathlib import Path

import tomli


def test_optional_dependencies_version_consistency():
"""Test that duplicate dependencies across groups have consistent version specifiers."""
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"

with open(pyproject_path, "rb") as f:
data = tomli.load(f)

optional_deps = data["project"]["optional-dependencies"]

# Collect all dependencies and their version specifiers with group info
dep_specs: dict[str, tuple[str, str]] = {}

for group_name, deps in optional_deps.items():
for dep in deps:
# Extract package name before any version specifier
name = dep
for op in [">=", "==", ">", "<", "~=", "!="]:
if op in name:
name = name.split(op)[0].strip()
break

# Remove extras like [sql] from name
if "[" in name:
name = name.split("[")[0].strip()

# Extract version specifier (everything after package name)
version_spec = dep[len(name) :].strip()
# Remove extras from version spec if present
if version_spec.startswith("["):
bracket_end = version_spec.find("]")
if bracket_end != -1:
version_spec = version_spec[bracket_end + 1 :].strip()

if name in dep_specs:
(previous_spec, first_group) = dep_specs[name]
assert previous_spec == version_spec, (
f"Version specifier mismatch for {name}: '{dep_specs[name]}'"
f" in [{first_group}] vs '{version_spec}' in [{group_name}]"
)
else:
dep_specs[name] = (version_spec, group_name)
Loading