Skip to content

Python: pre-commit improvements#2222

Merged
eavanvalkenburg merged 5 commits intomicrosoft:mainfrom
eavanvalkenburg:streamline_pre_commit
Nov 14, 2025
Merged

Python: pre-commit improvements#2222
eavanvalkenburg merged 5 commits intomicrosoft:mainfrom
eavanvalkenburg:streamline_pre_commit

Conversation

@eavanvalkenburg
Copy link
Member

@eavanvalkenburg eavanvalkenburg commented Nov 14, 2025

Motivation and Context

Our pre-commits were getting very slow, and this was mostly due to check md code blocks.

Description

Added file handling based on the pre-commit for check_md_code_block formatting, they now only run on changed .md files.
Also ensured pyright on pre-commit checks which packages need to be checked, also speeding things up.

Cleanup

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 November 14, 2025 13:13
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Nov 14, 2025

Python Test Coverage

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

Python Unit Test Overview

Tests Skipped Failures Errors Time
2039 129 💤 0 ❌ 0 🔥 40.675s ⏱️

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 improves the performance of pre-commit hooks by implementing selective file processing. The key optimization is to run checks only on changed files and their associated packages rather than the entire codebase.

  • Added file-based filtering for markdown code block linting via a new --no-glob flag
  • Created a new script to run pyright checks only on packages with changed files
  • Refactored pre-commit task configuration to pass changed files to checking tools

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/run_tasks_in_changed_packages.py New script that identifies which packages have changed files and runs tasks only in those packages
python/pyproject.toml Updated pre-commit tasks to accept file arguments and pass them to the new selective checking scripts; added missing coverage entries and removed unused doc tasks
python/check_md_code_blocks.py Added --no-glob flag to treat file arguments as literal paths instead of glob patterns
python/.pre-commit-config.yaml Removed pass_filenames: false to enable passing changed files to the check command
python/packages/chatkit/pyproject.toml Fixed typo: changed extend to extends for pyright configuration
python/packages/anthropic/tests/test_anthropic_client.py Added env_file_path parameter to improve test isolation

@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Nov 14, 2025
Merged via the queue into microsoft:main with commit 9e69e66 Nov 14, 2025
23 checks passed
arisng pushed a commit to arisng/agent-framework that referenced this pull request Feb 2, 2026
* pre-commit improvements

* updated lock

* fix for globbing

* reuse logic for mypy

* updated ci-mypy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants