Closed aatango closed 8 months ago
what codepage have you confused on Windows? have you tried enabling utf8 mode?
Activating the (still beta) support for UTF-8 mode in Windows appears to bypass the issue. In this mode, executing the script within the context of a git commit does not throw an error; a JSON file is properly formatted.
However, this is still an experimental support from Windows, and activating it causes problems elsewhere.
how about python's utf8 mode?
Setting the environment variable PYTHONUTF8=1
did solve the issue. Thank you for the help.
SETUP
Change to a (new) repository on Windows;
use the following
.pre-commit-config.yaml
configuration:add a new JSON file with a non-ascii filename, for example:
漢字.json
, orעִבְרִית.json
; andattempt to commit both the pre-commit configuration and the JSON file to your repository.
EXPECTED
The newly added JSON file is properly handled both when running
git commit
, or the individualpretty_format_json.py
file.ACTUAL
pretty_format_json.py $FILENAME --no-sort-keys --indent 2 --autofix
, everything works as expected.pretty_format_json
runs as part of a hook, the following error is thrown:NOTE
The error can be reproduced on Windows 10, but not on Ubuntu. Both have Python 3.10.