Skip to content

Python: Replace wildcard imports with explicit imports#3908

Merged
eavanvalkenburg merged 3 commits intomicrosoft:mainfrom
eavanvalkenburg:fix-3605-wildcard-imports
Feb 13, 2026
Merged

Python: Replace wildcard imports with explicit imports#3908
eavanvalkenburg merged 3 commits intomicrosoft:mainfrom
eavanvalkenburg:fix-3605-wildcard-imports

Conversation

@eavanvalkenburg
Copy link
Member

Fixes #3605

Summary

Replaced all wildcard imports (from ... import *) with explicit symbol imports across the Python codebase.

Changes

  • Core package (agent_framework/__init__.py): Replaced 10 wildcard imports with explicit imports for ~100 symbols
  • OpenAI subpackage (agent_framework/openai/__init__.py): Replaced 6 wildcard imports with explicit imports
  • Lab namespace packages: Replaced 3 wildcard imports with explicit imports and added __all__ declarations for re-exports
  • CODING_STANDARD.md: Added explicit guidance prohibiting wildcard imports with rationale

Impact

  • API: No breaking changes - all previously exported symbols remain available
  • Clarity: Makes public API explicit and improves code navigation
  • Performance: Eliminates unnecessary symbol resolution during imports
  • Tooling: Better IDE autocomplete, go-to-definition, and type checking

Testing

  • Ran core test suite: 812 passed, 18 skipped
  • Verified ruff checks pass on all modified files
  • Confirmed wildcard import count: 19 → 0

Wildcard Count

  • Before: 19 wildcard imports
  • After: 0 wildcard imports

- Replace all 'from ... import *' with explicit symbol imports
- Add __all__ declarations to namespace packages for re-exports
- Update CODING_STANDARD.md to prohibit wildcard imports
- Maintain exported API and preserve all functionality

fixes microsoft#3605
Copilot AI review requested due to automatic review settings February 13, 2026 09:55
@eavanvalkenburg eavanvalkenburg self-assigned this Feb 13, 2026
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python lab Agent Framework Lab labels Feb 13, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 13, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL20472324784% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
3918 225 💤 0 ❌ 0 🔥 1m 7s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request successfully eliminates all wildcard imports (from ... import *) across the Python codebase and replaces them with explicit symbol imports. The changes affect the core agent_framework package, the openai subpackage, and three lab namespace packages (tau2, lightning, gaia).

Changes:

  • Replaced 10 wildcard imports in the core package with ~100 explicit imports using the import X as X pattern for re-exporting
  • Replaced 6 wildcard imports in the OpenAI subpackage with explicit imports
  • Replaced 3 wildcard imports in lab namespace packages and added __all__ declarations
  • Updated CODING_STANDARD.md to prohibit wildcard imports and document the rationale

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/packages/core/agent_framework/init.py Replaced 10 wildcard imports with 387 lines of explicit imports using import X as X pattern
python/packages/core/agent_framework/openai/init.py Replaced 6 wildcard imports with explicit imports for 13 symbols
python/packages/lab/namespace/agent_framework/lab/tau2/init.py Replaced wildcard import with explicit imports for 6 symbols and added __all__
python/packages/lab/namespace/agent_framework/lab/lightning/init.py Replaced wildcard import with explicit import for 1 symbol and added __all__
python/packages/lab/namespace/agent_framework/lab/gaia/init.py Replaced wildcard import with explicit imports for 10 symbols and added __all__
python/CODING_STANDARD.md Added prohibition of wildcard imports with rationale and examples

@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Feb 13, 2026
Merged via the queue into microsoft:main with commit 4452997 Feb 13, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lab Agent Framework Lab python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: all: Review and clarify public imports and * usage

4 participants