Skip to content

Python: replace pre-commit with prek, add PEP 723 script deps, clean up dev dependencies#3748

Open
eavanvalkenburg wants to merge 15 commits intomicrosoft:mainfrom
eavanvalkenburg:prek
Open

Python: replace pre-commit with prek, add PEP 723 script deps, clean up dev dependencies#3748
eavanvalkenburg wants to merge 15 commits intomicrosoft:mainfrom
eavanvalkenburg:prek

Conversation

@eavanvalkenburg
Copy link
Member

Summary

This PR modernizes the Python tooling and dependency management across the monorepo.

Changes

Replace pre-commit with prek

  • Replaced pre-commit with prek, a Rust-native drop-in replacement that is significantly faster
  • Moved 5 hooks to repo: builtin for zero-clone, Rust-native execution: check-toml, check-yaml, check-json, end-of-file-fixer, mixed-line-ending
  • Added 4 new builtin hooks: trailing-whitespace, check-merge-conflict, detect-private-key, check-added-large-files
  • Updated all hook versions to latest: pre-commit-hooks v6, pyupgrade v3.21.2, bandit 1.9.3, uv-pre-commit 0.10.0
  • Updated CI workflow to use j178/prek-action@v1
  • Updated all poe tasks, scripts, and documentation

PEP 723 inline script metadata for samples

  • Added PEP 723 inline script metadata to 34 sample files that use external dependencies (autogen, semantic-kernel, azure-monitor, etc.)
  • Each sample now includes a run comment: uv run samples/path/to/script.py
  • This makes samples self-contained and runnable without installing external deps into the workspace

Dev dependency cleanup

  • Removed autogen-agentchat and autogen-ext[openai] from dev deps (now declared per-sample via PEP 723)
  • Removed unused dev deps: pytest-env (no config found), tomli-w (zero imports)

Core version lower bounds

  • Added >=1.0.0b260130 lower bound to agent-framework-core dependency in all 21 non-core packages
  • Ensures consistent minimum version requirements across the monorepo

Documentation updates

  • CODING_STANDARD.md: Added Versioning and Core Dependency section with policy for version bumps
  • SAMPLE_GUIDELINES.md: Extracted sample-specific standards (file structure, PEP 723 usage, syntax checking) into dedicated doc
  • AGENTS.md: Replaced inline sample section with link to SAMPLE_GUIDELINES.md
  • DEV_SETUP.md: Updated all pre-commit references to prek

Files changed: 65

…up dev dependencies

- Replace pre-commit with prek (Rust-native, faster pre-commit alternative)
- Move supported hooks to repo: builtin for zero-clone speed
- Add new builtin hooks: trailing-whitespace, check-merge-conflict, detect-private-key, check-added-large-files
- Update all hook versions to latest (pre-commit-hooks v6, pyupgrade v3.21.2, bandit 1.9.3, uv-pre-commit 0.10.0)
- Add PEP 723 inline script metadata to 34 samples with external deps
- Remove autogen-agentchat/autogen-ext from dev deps (now declared per-sample)
- Remove unused dev deps: pytest-env, tomli-w
- Add agent-framework-core>=1.0.0b260130 lower bound to all 21 packages
- Update CI workflow to use j178/prek-action
- Update docs: DEV_SETUP.md, AGENTS.md, CODING_STANDARD.md, SAMPLE_GUIDELINES.md
@eavanvalkenburg eavanvalkenburg requested a review from a team as a code owner February 7, 2026 13:06
Copilot AI review requested due to automatic review settings February 7, 2026 13:06
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python lab Agent Framework Lab labels Feb 7, 2026
@github-actions github-actions bot changed the title python: replace pre-commit with prek, add PEP 723 script deps, clean up dev dependencies Python: replace pre-commit with prek, add PEP 723 script deps, clean up dev dependencies Feb 7, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 7, 2026

Python Test Coverage

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

Python Unit Test Overview

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

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

Modernizes the Python developer tooling for the monorepo by switching from pre-commit to prek, cleaning up workspace dev dependencies, and making samples self-contained via PEP 723 inline metadata.

Changes:

  • Replace pre-commit with prek across local tooling and CI, and update hook versions/config.
  • Add PEP 723 inline script metadata to samples that require external dependencies and document new sample guidelines.
  • Normalize non-core packages to depend on agent-framework-core>=1.0.0b260130 and remove unused dev dependencies.

Reviewed changes

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

Show a summary per file
File Description
python/uv.lock Removes pre-commit and other no-longer-needed deps; adds prek; updates resolved dependency graph accordingly.
python/pyproject.toml Updates dev dependency group (adds prek, removes pre-commit/unused deps) and renames Poe tasks from pre-commit-* to prek-*.
python/.pre-commit-config.yaml Moves several hooks to repo: builtin, updates hook revisions, and points the Poe hook at prek-check.
.github/workflows/python-code-quality.yml Switches CI job from pre-commit to prek using j178/prek-action@v1 and updates caching paths/keys.
python/devsetup.sh Updates dev setup script to install prek hooks via Poe.
python/DEV_SETUP.md Updates documentation to refer to prek instead of pre-commit and adjusts the suggested commands.
python/CODING_STANDARD.md Documents policy for bumping agent-framework-core lower bounds in non-core packages.
python/AGENTS.md Replaces embedded sample guidance with a link to samples/SAMPLE_GUIDELINES.md.
python/.vscode/tasks.json Updates VS Code task to run prek instead of pre-commit.
python/samples/SAMPLE_GUIDELINES.md Adds explicit sample file structure + PEP 723 dependency guidance and notes on samples syntax checking.
python/samples/semantic-kernel-migration/processes/nested_process.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/processes/fan_out_fan_in_process.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/sequential.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/magentic.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/handoff.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/group_chat.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/orchestrations/concurrent_basic.py Adds PEP 723 metadata and adjusts imports in the orchestration sample.
python/samples/semantic-kernel-migration/openai_responses/01_basic_responses_agent.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_responses/02_responses_agent_with_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_responses/03_responses_agent_structured_output.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_assistant/01_basic_openai_assistant.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_assistant/02_openai_assistant_with_code_interpreter.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/openai_assistant/03_openai_assistant_function_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/copilot_studio/01_basic_copilot_studio_agent.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/copilot_studio/02_copilot_studio_streaming.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/chat_completion/01_basic_chat_completion.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/chat_completion/02_chat_completion_with_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/chat_completion/03_chat_completion_thread_and_stream.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/azure_ai_agent/01_basic_azure_ai_agent.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/azure_ai_agent/02_azure_ai_agent_with_code_interpreter.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/semantic-kernel-migration/azure_ai_agent/03_azure_ai_agent_threads_and_followups.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/getting_started/observability/agent_with_foundry_tracing.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/getting_started/evaluation/self_reflection/self_reflection.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/getting_started/agents/copilotstudio/copilotstudio_with_explicit_settings.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/demos/chatkit-integration/app.py Adds PEP 723 metadata to make the demo runnable standalone.
python/samples/demos/m365-agent/m365_agent_demo/app.py Adds PEP 723 metadata at top of file (but currently results in duplicated metadata blocks).
python/samples/autogen-migration/single_agent/01_basic_assistant_agent.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/single_agent/02_assistant_agent_with_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/single_agent/03_assistant_agent_thread_and_stream.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/single_agent/04_agent_as_tool.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/orchestrations/01_round_robin_group_chat.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/orchestrations/02_selector_group_chat.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/orchestrations/03_swarm.py Adds PEP 723 metadata to make the sample runnable standalone.
python/samples/autogen-migration/orchestrations/04_magentic_one.py Adds PEP 723 metadata to make the sample runnable standalone.
python/packages/a2a/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/ag-ui/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/anthropic/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/azure-ai-search/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/azure-ai/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/azurefunctions/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/bedrock/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/chatkit/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/claude/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/copilotstudio/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/declarative/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/devui/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/durabletask/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/foundry_local/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/github_copilot/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/lab/pyproject.toml Adds core lower bound and replaces pre-commit with prek in the package’s dev group.
python/packages/mem0/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/ollama/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/orchestrations/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/purview/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
python/packages/redis/pyproject.toml Adds agent-framework-core>=1.0.0b260130 lower bound.
Comments suppressed due to low confidence (1)

python/samples/semantic-kernel-migration/orchestrations/concurrent_basic.py:22

  • ConcurrentBuilder is used later in this sample (ConcurrentBuilder(participants=[...]).build()), but it is no longer imported after this change. Add the appropriate import (e.g., from agent_framework.orchestrations import ConcurrentBuilder) or adjust the code to use the correct symbol that is already imported.

Remove global 'files: ^python/' filter and strip python/ prefix from all path patterns in .pre-commit-config.yaml so prek finds files when run from the python/ directory. Update CI workflow to use --cd python instead of --config path. Include trailing whitespace fixes and dev dependency cleanup.
Write a temp pyrightconfig.json matching pyrightconfig.samples.json rules (typeCheckingMode=off, only reportMissingImports and reportAttributeAccessIssue). Filter output to only fail on these rules since syntax-level errors (top-level await, undefined vars) are expected in README documentation snippets.
…list

The prek-markdown-code-lint task received all changed files including non-README markdown and files with pre-existing broken imports. Replace with the standard markdown-code-lint task which uses the correct glob patterns (README.md, packages/**/README.md, samples/**/*.md).
- ag-ui: replace TextContent (removed) with content.type == 'text'
- durabletask: fix import path to durabletask.worker.TaskHubGrpcWorker
- orchestrations: use constructor params instead of .participants() method
- observability: mark deprecated code blocks as plain text, filter
  reportMissingImports to agent_framework modules only
- remove README excludes from markdown-code-lint task
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.

2 participants