Skip to content

Commit b17c90f

Browse files
committed
Fix encoding issue on Windows
1 parent 550112d commit b17c90f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

sync_pre_commit_deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def main(argv: Sequence[str] | None = None) -> int:
4747
yaml.preserve_quotes = True
4848
yaml.indent(yaml_mapping, yaml_sequence, yaml_offset)
4949

50-
with open(filename) as f:
50+
with open(filename, encoding='utf-8') as f:
5151
loaded = yaml.load(f)
5252

5353
# TODO - validate schema?

tests/sync_pre_commit_deps_test.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,20 @@
3535
' - mypy==0.123\n',
3636
id='local hook shadows supported lib',
3737
),
38+
pytest.param(
39+
'repos:\n'
40+
'- repo: https://github.com/psf/black\n'
41+
' rev: 23.3.0\n'
42+
' hooks:\n'
43+
' - name: \N{SNOWMAN} black\n'
44+
' id: black\n',
45+
id='unicode no-op',
46+
),
3847
),
3948
)
4049
def test_main_noop(tmpdir, s):
4150
cfg = tmpdir.join('.pre-commit-config.yaml')
42-
cfg.write(s)
51+
cfg.write_binary(s.encode())
4352

4453
assert not main((str(cfg),))
4554

0 commit comments

Comments
 (0)