Skip to content

Conversation

eavanvalkenburg
Copy link
Member

Motivation and Context

Made some improvements to the loading setup.
In the main package, all modules are just loaded, there is very little gain in lazy loading and it leads to extra complexity.
Now added a __all__ to each file, that is the only place you need to specify what is part of the public API for that file.
In the main init all submodules are loaded with the *, which type checkers understand as loading everything from all.

In Azure, and that can be the blueprint for all files, simplified the setup as well:

  • add public components to _IMPORTS variable and to init.pyi
  • currently there is no way to do a multilevel import in a subpackage, so keep all packages simple with single level imports, which is desired anyway.

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the SK Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • I didn't break anyone 😄

@Copilot Copilot AI review requested due to automatic review settings July 18, 2025 12:30
Copy link
Contributor

@Copilot 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 PR improves the Python package loading structure by standardizing the use of __all__ declarations and simplifying import patterns. The changes move away from lazy loading in favor of explicit star imports that leverage __all__ for better type checker compatibility.

Key changes:

  • Adds __all__ declarations to all module files to define public APIs
  • Replaces lazy loading with star imports in __init__.py files
  • Simplifies the Azure package loading mechanism

Reviewed Changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
agent_framework/init.py Replaced lazy loading with star imports from submodules
agent_framework/init.pyi Removed type stub file (now handled by all declarations)
agent_framework/azure/init.py Simplified loading mechanism and improved error handling
agent_framework/azure/init.pyi Added type stub for Azure package imports
Multiple module files Added all declarations to define public APIs
.vscode/settings.json Updated code actions to use Ruff-specific settings

@dmytrostruk dmytrostruk added this pull request to the merge queue Jul 18, 2025
Merged via the queue into microsoft:main with commit 9287572 Jul 18, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants