Skip to content

Support empty .pre-commit-config.yaml files#906

Merged
nathanjmcdougall merged 2 commits intomainfrom
663-cope-with-empty-pre-commit-configyaml-files
Jul 25, 2025
Merged

Support empty .pre-commit-config.yaml files#906
nathanjmcdougall merged 2 commits intomainfrom
663-cope-with-empty-pre-commit-configyaml-files

Conversation

@nathanjmcdougall
Copy link
Copy Markdown
Collaborator

No description provided.

@nathanjmcdougall nathanjmcdougall linked an issue Jul 25, 2025 that may be closed by this pull request
@nathanjmcdougall nathanjmcdougall requested a review from Copilot July 25, 2025 03:09
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 enables support for empty .pre-commit-config.yaml files by modifying the validation logic to automatically add a repos: [] field to empty YAML configurations instead of raising an error.

  • Modifies _validate_config function to handle empty YAML configurations by adding default repos: []
  • Updates test to verify empty files are now valid and can be edited
  • Removes unused imports related to error handling for empty configurations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/usethis/_integrations/pre_commit/io_.py Adds logic to populate empty YAML configs with default repos: [] field and moves import to runtime
tests/usethis/_integrations/pre_commit/test_pre_commit_io_.py Updates test to verify empty configs are valid and removes unused imports

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jul 25, 2025

CodSpeed Instrumentation Performance Report

Merging #906 will not alter performance

Comparing 663-cope-with-empty-pre-commit-configyaml-files (5dfd1cb) with main (4a05d76)1

Summary

✅ 2 untouched benchmarks

Footnotes

  1. No successful run was found on main (f8b9614) during the generation of this report, so 4a05d76 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@nathanjmcdougall nathanjmcdougall merged commit 73770d2 into main Jul 25, 2025
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the 663-cope-with-empty-pre-commit-configyaml-files branch July 25, 2025 03:35
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.

Cope with empty .pre-commit-config.yaml files

2 participants