Skip to content

Conversation

Copy link

Copilot AI commented Feb 9, 2026

Description

Adds tests for set_version() methods to verify encoding behavior during version updates (the cz bump path). While adding tests, discovered multiple providers weren't using configured encoding when writing files.

Tests Added

  • test_json_provider_set_version_uses_encoding_with_encoding_fixture - Verifies JsonProvider writes non-ASCII content correctly
  • test_toml_provider_set_version_uses_encoding_with_encoding_fixture - Verifies TomlProvider writes non-ASCII content correctly

Both tests use existing fixtures with Cyrillic characters and verify version updates preserve non-ASCII content.

Encoding Bugs Fixed

  • JsonProvider.set_version() - Now uses encoding parameter and ensure_ascii=False
  • TomlProvider.set_version() - Now uses encoding parameter
  • UvProvider.set_lock_version() - Added encoding for pyproject.toml and uv.lock I/O
  • CargoProvider.set_lock_version() - Added encoding for Cargo.toml and Cargo.lock I/O
  • NpmProvider - Added _get_encoding() method; applied to all file operations (package.json, package-lock.json, npm-shrinkwrap.json)

Checklist

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

  • Yes (please specify the tool below)

Generated-by: GitHub Copilot following the guidelines

Code Changes

  • Add test cases to all the changes you introduce
  • Run uv run poe all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run uv run poe doc locally to ensure the documentation pages renders correctly
  • Check and fix any broken internal documentation links (internal or external)

Expected Behavior

Version files containing non-ASCII characters (e.g., UTF-8 with Cyrillic, emoji, CJK) should maintain encoding integrity through get_version() and set_version() operations when encoding is configured.

Steps to Test This Pull Request

  1. Run python -m pytest tests/providers/test_base_provider.py -v
  2. Verify all 10 tests pass, including the two new set_version tests
  3. Run python -m pytest tests/providers/test_npm_provider.py tests/providers/test_cargo_provider.py -v
  4. Verify all existing provider tests still pass

Additional Context

Addresses feedback from #1857 review comment requesting set_version() test coverage. The encoding bugs were latent issues - existing get_version() tests only caught half the problem.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 9, 2026 08:04
Co-authored-by: bearomorphism <26526132+bearomorphism@users.noreply.github.com>
Co-authored-by: bearomorphism <26526132+bearomorphism@users.noreply.github.com>
Co-authored-by: bearomorphism <26526132+bearomorphism@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on encoding settings in provider config PR Add set_version encoding tests and fix missing encoding in provider writes Feb 9, 2026
Copilot AI requested a review from bearomorphism February 9, 2026 08:07
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.

2 participants