Skip to content

Python: declare the two integration exports the runtime already serves - #10201

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
lxcxjxhx:python/stub-missing-exports
Nov 11, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
lxcxjxhx:python/stub-missing-exports

Conversation

@lxcxjxhx

Copy link
Copy Markdown
Contributor

Two optional-integration stubs omit names their runtime already serves, so type checkers reject imports that work.

agent_framework.anthropic:

_IMPORTS: dict[str, tuple[str, str]] = {
    ...
    "RawClaudeAgent": ("agent_framework_claude", "agent-framework-claude"),
}

agent_framework.foundry:

    "FoundryAgentOptions": ("agent_framework_foundry", "agent-framework-foundry"),

Both resolve at runtime through __getattr__, but neither appears in the corresponding __init__.pyi, so ty/mypy/pyright report them as unknown. RawClaudeAgent is also listed in the module docstring's "Supported classes" and belongs to the agent_framework_claude group, which is where the stub's gap shows most clearly:

from agent_framework_claude import ClaudeAgent, ClaudeAgentOptions

Change

  • anthropic/__init__.pyi: RawClaudeAgent added to the agent_framework_claude import (the module the runtime maps it to) and to __all__.
  • foundry/__init__.pyi: FoundryAgentOptions added to the agent_framework_foundry import and to __all__.

Two files, +4/−1, no runtime code touched.

How these were found

Every __init__.pyi is compared against its __init__.py, both parsed with ast: the stub's symbols are the names in its from … import statements plus __all__; the runtime's are the keys of _IMPORTS when it maps symbol → (module, distribution), or its entries when it is a plain list, plus __all__. Stdlib imports are excluded — without that, from typing import Final in the core stub is reported as a "stub-only export".

After this change the sweep is:

21 in sync; 1 with drift (the typing.Final false positive); 0 unverifiable

Before it, three names were reported: these two, and that false positive. Every other namespace package under python/packages/core matches its stub exactly.

Run against the parent of #10170, the same comparison reproduces the six names that PR added, so it is known to catch this class rather than merely agreeing with the current state.

`agent_framework.anthropic` serves RawClaudeAgent and `agent_framework.foundry`
serves FoundryAgentOptions through the lazy namespace, but neither stub lists
them, so type checkers reject an import that works at runtime. Both names are
added to the matching `from ... import` block and to `__all__`.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the optional-integration type-stub export updates.

No open issues 🎉

What changed in this PR

Aligns two optional-integration type stubs with exports already available at runtime, allowing type checkers to recognize valid imports.

Changes:

  • Adds RawClaudeAgent to the Anthropic stub’s imports and __all__.
  • Adds FoundryAgentOptions to the Foundry stub’s imports and __all__.
  • Changes declarations only; runtime behavior remains unchanged.
File Description
python/​packages/​core/​agent_framework/​foundry/​__init__.pyi Declares the existing FoundryAgentOptions export.
python/​packages/​core/​agent_framework/​anthropic/​__init__.pyi Declares the existing RawClaudeAgent export.

Review effort: Balanced

Merged via the queue into microsoft:main with commit b057cd4 Nov 11, 2026
44 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 5c2cc86c Deployed Nov 10, 2026 by lxcxjxhx via add_label #27451
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants