Migrate the pre-commit and bitbucket YAML integrations to use FileManagers#1247
Merged
nathanjmcdougall merged 8 commits intomainfrom Dec 29, 2025
Conversation
…mic-write-based FileManager framework consistent with other config files
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates pre-commit and Bitbucket YAML integrations to use the atomic-write-based FileManager framework, consolidating them with the patterns used by other config files in the project.
Key changes:
- Replaced context manager-based I/O functions with manager classes that handle validation and commits
- Moved error classes to dedicated error modules for better organization
- Extracted file initialization logic into separate
init.pymodules - Consolidated dump functions into YAML manager classes
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/usethis/_integrations/pre_commit/yaml.py |
New manager class for pre-commit config with validation and commit methods |
src/usethis/_integrations/pre_commit/init.py |
Extracted file initialization logic |
src/usethis/_integrations/pre_commit/errors.py |
Added config error class |
src/usethis/_integrations/pre_commit/hooks.py |
Updated to use manager instead of context managers |
src/usethis/_integrations/pre_commit/version.py |
Updated to use manager API |
src/usethis/_integrations/pre_commit/io_.py |
Removed (replaced by yaml.py) |
src/usethis/_integrations/pre_commit/dump.py |
Removed (merged into yaml.py) |
src/usethis/_integrations/ci/bitbucket/yaml.py |
New manager class with script_items anchor handling |
src/usethis/_integrations/ci/bitbucket/init.py |
Extracted file initialization logic |
src/usethis/_integrations/ci/bitbucket/errors.py |
Added schema error class |
src/usethis/_integrations/ci/bitbucket/steps.py |
Refactored to use model-based operations instead of doc |
src/usethis/_integrations/ci/bitbucket/cache.py |
Updated to use manager API |
src/usethis/_integrations/ci/bitbucket/pipeweld.py |
Updated to use manager API |
src/usethis/_integrations/ci/bitbucket/io_.py |
Removed (replaced by yaml.py) |
src/usethis/_integrations/ci/bitbucket/dump.py |
Removed (merged into yaml.py) |
src/usethis/_integrations/pydantic/dump.py |
Added YAMLLiteral to type alias |
src/usethis/_integrations/file/yaml/update.py |
Relaxed type to accept dict in addition to YAMLLiteral |
src/usethis/_config_file.py |
Added managers to files_manager context |
tests/ |
Updated all tests to use new manager APIs |
…eferred-file-write-file-manager-approach
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
CodSpeed Performance ReportMerging #1247 will improve performance by 33.19%Comparing Summary
Benchmarks breakdown
|
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.
Using the atomic-write-based FileManager framework consistent with other config files