Python: pre-commit improvements#2222
Merged
eavanvalkenburg merged 5 commits intomicrosoft:mainfrom Nov 14, 2025
Merged
Conversation
Member
Contributor
There was a problem hiding this comment.
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-globflag - 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 |
dmytrostruk
approved these changes
Nov 14, 2025
TaoChenOSU
approved these changes
Nov 14, 2025
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
.mdfiles.Also ensured pyright on pre-commit checks which packages need to be checked, also speeding things up.
Cleanup
Contribution Checklist