Skip to content

Broadening argument type for load_configuration_from_env - #552

Merged
Rodrigo Brandão (rodrigobr-msft) merged 4 commits into
mainfrom
users/robrandao/load-config
Aug 19, 2026
Merged

Broadening argument type for load_configuration_from_env#552
Rodrigo Brandão (rodrigobr-msft) merged 4 commits into
mainfrom
users/robrandao/load-config

Conversation

@rodrigobr-msft

Copy link
Copy Markdown
Contributor

This pull request refines the load_configuration_from_env function to improve type safety and avoid potential side effects when handling environment variables. The most important changes are:

Type safety and immutability improvements:

  • Changed the type annotation for the env_vars parameter in load_configuration_from_env from dict[str, Any] to Mapping[str, Any], allowing for more flexible and type-safe usage.
  • Replaced the use of env_vars.copy() with copy(env_vars) to create a shallow copy, ensuring that the original mapping is not mutated and supporting non-dict mappings.
  • Renamed the local variable from vars to local_vars for clarity and to avoid shadowing the built-in vars() function.

Copilot AI lite review requested due to automatic review settings August 19, 2026 22:11

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.

Pull request overview

This PR updates load_configuration_from_env in the Activity library to accept broader mapping types for environment-variable parsing, aiming to improve type-safety and reduce unintended side effects when handling env var sources.

Changes:

  • Broadened env_vars parameter type from dict[str, Any] to Mapping[str, Any].
  • Avoided the local name vars (which shadows the built-in vars()).
  • Switched from env_vars.copy() to copy(env_vars) to support non-dict mappings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 19, 2026 22:16
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) marked this pull request as ready for review August 19, 2026 22:19

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.

Pull request overview

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

Suppressed comments (1)

libraries/microsoft-agents-activity/microsoft_agents/activity/config/_load_configuration.py:9

  • The return type is still an unparameterized dict, which limits the type-safety improvements from widening env_vars to Mapping[str, Any]. This codebase commonly uses parameterized dict return types (e.g., microsoft_agents/activity/channel_account.py:37 returns dict[str, Any]).
def load_configuration_from_env(env_vars: Mapping[str, Any]) -> dict:

Copilot AI review requested due to automatic review settings August 19, 2026 22:20

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.

Pull request overview

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

@rodrigobr-msft Rodrigo Brandão (rodrigobr-msft) changed the title Expanding typing argument type for load_configuration_from_env Expanding argument type for load_configuration_from_env Aug 19, 2026
@rodrigobr-msft Rodrigo Brandão (rodrigobr-msft) changed the title Expanding argument type for load_configuration_from_env Broadening argument type for load_configuration_from_env Aug 19, 2026
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) merged commit 37e7fc5 into main Aug 19, 2026
11 checks passed
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) deleted the users/robrandao/load-config branch August 19, 2026 22:28
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.

3 participants