Merged
Conversation
Contributor
|
Thank you for contributing! 👋 |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issue #168 by ensuring proper Unicode handling when reading and writing Python files during formatting and linting operations.
Key Changes:
- Added explicit UTF-8 encoding to all file read/write operations across the codebase
- Replaced
read_text()/write_text()withshutil.copyfile()in the diff generation path for better encoding preservation - Added a test fixture that forces ASCII encoding by default to catch any missing encoding specifications
- Added comprehensive test cases with Unicode characters (©, π, Gerät, デバイス, 장치, 设备, etc.) to verify the fix
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_cli/test_format.py | Added explicit UTF-8 encoding to test file reading to properly handle Unicode content |
| ni_python_styleguide/_utils/code_analysis.py | Added UTF-8 encoding to file reading in import region analysis |
| ni_python_styleguide/_fix.py | Added DEFAULT_ENCODING to multiple read/write operations and replaced read_text/write_text with shutil.copyfile for better encoding preservation |
| tests/conftest.py | Added autouse test fixture to force ASCII encoding by default, catching any missing encoding specifications |
| pyproject.toml | Removed unnecessary blank line for code cleanup |
| tests/test_cli/format_test_cases__snapshots/file_with_unicode/* | Added new test case files containing various Unicode characters to validate the fix |
| tests/test_cli/fix_test_cases__snapshots/unicode_example/* | Added test case files for Unicode handling in the fix command |
| tests/test_cli/acknowledge_existing_errors_test_cases__snapshots/unicode_in_files/* | Extended existing test case with additional Unicode data |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
irwand
approved these changes
Nov 13, 2025
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.
Adds a test for and fixes #168