Skip to content

Conversation

@bearomorphism
Copy link
Collaborator

Description

Checklist

Was generative AI tooling used to co-author this PR?

  • Yes (please specify the tool below)

Cursor

Steps to Test This Pull Request

Run uv run poe test.

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.98%. Comparing base (a03739f) to head (16d8ee8).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1855      +/-   ##
==========================================
- Coverage   97.99%   97.98%   -0.01%     
==========================================
  Files          60       60              
  Lines        2692     2684       -8     
==========================================
- Hits         2638     2630       -8     
  Misses         54       54              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

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

Refactors file IO across core Commitizen commands/config and the test suite to use pathlib.Path convenience APIs (read_text, read_bytes, write_bytes, etc.), reducing boilerplate and aligning IO patterns.

Changes:

  • Replace open(...).read()/Path.open(...).read() patterns with Path.read_text() in tests and info() helpers.
  • Replace binary config reads/writes with Path.read_bytes() / Path.write_bytes() in TOML config handling and config loading.
  • Adjust a commit-command test fixture to write/read the backup message using Path utilities and correct working-directory expectations.

Reviewed changes

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

Show a summary per file
File Description
tests/test_conf.py Simplifies TOML config content assertions using Path.read_text().
tests/test_changelog.py Uses Path.read_text() for loading changelog fixture content.
tests/test_bump_update_version_in_files.py Replaces manual file opening with Path.read_text() when aggregating regression output.
tests/conftest.py Switches to append-mode writes via open(..., "a") for generated pyproject.toml test content.
tests/commands/test_init_command.py Reads generated config files via Path.read_text() and parses JSON/YAML from strings.
tests/commands/test_commit_command.py Updates backup-message fixture to use Path.write_text() and ensure correct cwd for the command.
tests/commands/test_check_command.py Updates mocks to patch Path.read_text() instead of open().
tests/commands/test_changelog_command.py Replaces repeated file reads with Path.read_text() across changelog command tests.
tests/commands/test_bump_command.py Uses append-mode Path.open("a") and Path.read_text() for assertions on bumped files.
commitizen/cz/jira/jira.py Uses Path.read_text() for bundled info text.
commitizen/cz/customize/customize.py Uses Path(info_path).read_text() for external info file support.
commitizen/cz/conventional_commits/conventional_commits.py Uses Path.read_text() for bundled info text.
commitizen/config/toml_config.py Simplifies TOML reads/writes with read_bytes() / write_bytes().
commitizen/config/init.py Loads config bytes via Path.read_bytes() when creating config objects.
commitizen/commands/commit.py Uses Path.read_text() when reading the temporary editor file and backup message.
commitizen/commands/check.py Uses Path.read_text() to load commit messages from --commit-msg-file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bearomorphism bearomorphism changed the title test: use pathlib utilities to shorten code refactor: use pathlib utilities to shorten code Feb 9, 2026
@bearomorphism
Copy link
Collaborator Author

@copilot what can you assist me with this PR?

Copy link

Copilot AI commented Feb 9, 2026

@bearomorphism I've opened a new pull request, #1856, to work on those changes. Once the pull request is ready, I'll request review from you.

@bearomorphism
Copy link
Collaborator Author

Thanks for quick review, Santi!

@bearomorphism bearomorphism merged commit fbafcaf into master Feb 9, 2026
20 checks passed
@bearomorphism bearomorphism deleted the pathlib-refactor branch February 9, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants