Skip to content

Python: Add samples syntax checking with pyright#3710

Merged
moonbox3 merged 6 commits intomicrosoft:mainfrom
eavanvalkenburg:check_samples
Feb 7, 2026
Merged

Python: Add samples syntax checking with pyright#3710
moonbox3 merged 6 commits intomicrosoft:mainfrom
eavanvalkenburg:check_samples

Conversation

@eavanvalkenburg
Copy link
Member

Motivation and Context

  • Add pyrightconfig.samples.json with relaxed type checking but import validation
  • Add samples-syntax poe task to check samples for syntax and import errors
  • Add samples-syntax to check and pre-commit-check tasks
  • Fix 78 sample errors:
    • Update workflow builder imports to use agent_framework_orchestrations
    • Change content type isinstance checks to content.type comparisons
    • Use Content factory methods instead of removed content type classes
    • Fix TypedDict access patterns for Annotation
    • Fix various API mismatches (normalize_messages, ChatMessage.text, role)

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings February 5, 2026 20:43
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Feb 5, 2026
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 PR adds syntax checking for Python samples using pyright with a relaxed configuration that validates imports and attribute access without strict type checking. The PR includes the pyright configuration, build task integration, and fixes to 78 sample errors related to import reorganization and API changes.

Changes:

  • Added pyrightconfig.samples.json with relaxed type checking configuration
  • Added samples-syntax poe task and integrated it into check and pre-commit-check workflows
  • Updated samples to import workflow builders from agent_framework_orchestrations package
  • Changed content type checking from isinstance() to .type property comparisons
  • Updated API usage for normalize_messages, ChatMessage.text, Role, Annotation access patterns, and Content factory methods

Reviewed changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
python/pyrightconfig.samples.json New pyright configuration for sample validation with import/attribute checking
python/pyproject.toml Added samples-syntax task and integrated into check/pre-commit workflows
python/AGENTS.md Documentation for samples syntax checking process and exclusions
python/samples/getting_started/workflows/*/*.py Updated imports from agent_framework to agent_framework_orchestrations for builders
python/samples/getting_started/tools/*.py Changed isinstance checks to content.type comparisons
python/samples/getting_started/orchestrations/*.py Updated imports and role access patterns
python/samples/getting_started/agents/*/*.py Updated Content factory method usage and annotation access patterns
python/samples/getting_started/context_providers/*.py Changed msg.content to msg.text
python/samples/demos/*/*.py Updated to use ExecutorEvent instead of AgentRunUpdateEvent
python/samples/autogen-migration/*/*.py Updated imports and content type checking patterns

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 6, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _types.py10399690%82, 91–92, 146, 151, 170, 172, 176, 180, 182, 184, 186, 204, 208, 234, 256, 261, 266, 270, 296, 300, 646–647, 1018, 1080, 1097, 1115, 1120, 1138, 1148, 1165–1166, 1168, 1186–1187, 1189, 1196–1197, 1199, 1234, 1245–1246, 1248, 1286, 1543, 1596, 1603, 1625, 1631, 1679, 1722–1727, 1749, 1754, 1883, 1895, 2134, 2143, 2163, 2255, 2476, 2681, 2751, 2763, 2770, 2781, 2985–2987, 2990–2992, 2996, 3001, 3005, 3117–3119, 3147, 3201, 3205–3207, 3209, 3220–3221, 3224–3228, 3234
TOTAL16546205987% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3920 225 💤 0 ❌ 0 🔥 1m 8s ⏱️

- Add pyrightconfig.samples.json with relaxed type checking but import validation
- Add samples-syntax poe task to check samples for syntax and import errors
- Add samples-syntax to check and pre-commit-check tasks
- Fix 78 sample errors:
  - Update workflow builder imports to use agent_framework_orchestrations
  - Change content type isinstance checks to content.type comparisons
  - Use Content factory methods instead of removed content type classes
  - Fix TypedDict access patterns for Annotation
  - Fix various API mismatches (normalize_messages, ChatMessage.text, role)
@moonbox3 moonbox3 added this pull request to the merge queue Feb 7, 2026
Merged via the queue into microsoft:main with commit 390f933 Feb 7, 2026
24 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 python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants