Skip to content

Migrate the pre-commit and bitbucket YAML integrations to use FileManagers#1247

Merged
nathanjmcdougall merged 8 commits intomainfrom
492-move-pre-commit-integration-to-use-the-deferred-file-write-file-manager-approach
Dec 29, 2025
Merged

Migrate the pre-commit and bitbucket YAML integrations to use FileManagers#1247
nathanjmcdougall merged 8 commits intomainfrom
492-move-pre-commit-integration-to-use-the-deferred-file-write-file-manager-approach

Conversation

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

@nathanjmcdougall nathanjmcdougall commented Dec 29, 2025

Using the atomic-write-based FileManager framework consistent with other config files

…mic-write-based FileManager framework consistent with other config files
@nathanjmcdougall nathanjmcdougall changed the title Migrate the pre-commit and bitbucket YAML integrations to use the ato… Migrate the pre-commit and bitbucket YAML integrations to use FileManagers Dec 29, 2025
Copy link
Copy Markdown
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 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.py modules
  • 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

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 29, 2025

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 29, 2025

CodSpeed Performance Report

Merging #1247 will improve performance by 33.19%

Comparing 492-move-pre-commit-integration-to-use-the-deferred-file-write-file-manager-approach (a599241) with main (72a4cb1)

Summary

⚡ 1 improvement
✅ 1 untouched

Benchmarks breakdown

Mode Benchmark BASE HEAD Efficiency
Simulation test_several_tools_add_and_remove 1,056.3 ms 793.1 ms +33.19%

@nathanjmcdougall nathanjmcdougall merged commit 7fa0576 into main Dec 29, 2025
19 checks passed
@nathanjmcdougall nathanjmcdougall deleted the 492-move-pre-commit-integration-to-use-the-deferred-file-write-file-manager-approach branch December 29, 2025 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move pre-commit integration to use the deferred file write File Manager approach

2 participants