Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions python/packages/anthropic/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ exclude_dirs = ["tests"]
executor.type = "uv"
include = "../../shared_tasks.toml"

[tool.poe.tasks.dependency-pyright]
help = "Run Pyright over Anthropic implementation files for isolated dependency validation."
cmd = "pyright --project pyrightconfig.dependency.json"

[tool.poe.tasks.mypy]
help = "Run MyPy for this package."
cmd = "mypy --config-file $POE_ROOT/pyproject.toml agent_framework_anthropic"
Expand Down
9 changes: 9 additions & 0 deletions python/packages/anthropic/pyrightconfig.dependency.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../pyproject.toml",
"include": [
"agent_framework_anthropic"
],
"exclude": [
"agent_framework_anthropic/_vertex_client.py"
]
}
4 changes: 4 additions & 0 deletions python/packages/openai/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ exclude_dirs = ["tests"]
executor.type = "uv"
include = "../../shared_tasks.toml"

[tool.poe.tasks.dependency-pyright]
help = "Run Pyright over OpenAI implementation files for isolated dependency validation."
cmd = "pyright --project pyrightconfig.dependency.json"

[tool.poe.tasks.mypy]
help = "Run MyPy for this package."
cmd = "mypy --config-file $POE_ROOT/pyproject.toml agent_framework_openai"
Expand Down
6 changes: 6 additions & 0 deletions python/packages/openai/pyrightconfig.dependency.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../pyproject.toml",
"include": [
"agent_framework_openai"
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft. All rights reserved.

import json
from collections.abc import Callable
from pathlib import Path

Expand Down Expand Up @@ -196,3 +197,34 @@ def test_dependency_pyright_reuses_root_test_requirements(tmp_path: Path) -> Non
"mcp[ws]",
]
assert command[-3:-1] == ["python", "-c"]


@pytest.mark.parametrize(
("package", "module"),
[("anthropic", "agent_framework_anthropic"), ("openai", "agent_framework_openai")],
)
def test_optional_namespace_packages_define_their_own_dependency_pyright_task(package: str, module: str) -> None:
"""Packages that type-check against deliberately optional namespaces need the probe escape hatch.

``agent_framework_anthropic`` references ``google.auth`` and ``agent_framework_openai`` references
``azure.core``/``azure.identity``, in both cases without declaring them, because those surfaces are
optional. A full workspace sync resolves them transitively, so repo-wide Pyright passes; an isolated
dependency probe does not, and the resulting ``reportMissingImports`` aborts the whole bounds gate.
"""
workspace_root = Path(__file__).resolve().parents[3]

plans = _build_test_plans(workspace_root, package)
Comment thread
manjunathshiva marked this conversation as resolved.

assert [plan.typing_task for plan in plans] == ["dependency-pyright"]

config = json.loads((workspace_root / f"packages/{package}/pyrightconfig.dependency.json").read_text())
assert config["include"] == [module]


def test_anthropic_dependency_pyright_config_excludes_the_vertex_client() -> None:
workspace_root = Path(__file__).resolve().parents[3]
config_path = workspace_root / "packages/anthropic/pyrightconfig.dependency.json"

config = json.loads(config_path.read_text())

assert config["exclude"] == ["agent_framework_anthropic/_vertex_client.py"]
Loading