Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sync_pre_commit_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main(argv: Sequence[str] | None = None) -> int:
yaml.preserve_quotes = True
yaml.indent(yaml_mapping, yaml_sequence, yaml_offset)

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

# TODO - validate schema?
Expand Down
14 changes: 12 additions & 2 deletions tests/sync_pre_commit_deps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,25 @@
' - mypy==0.123\n',
id='local hook shadows supported lib',
),
pytest.param(
'repos:\n'
'- repo: https://github.com/psf/black\n'
' rev: 23.3.0\n'
' hooks:\n'
' - name: \N{SNOWMAN} black\n'
' id: black\n',
id='unicode no-op',
),
),
)
def test_main_noop(tmpdir, s):
cfg = tmpdir.join('.pre-commit-config.yaml')
cfg.write(s)
cfg.write_binary(s.encode())

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

assert cfg.read() == s
with open(cfg, encoding='utf-8') as f:
assert f.read() == s


def test_main_writes_all(tmpdir):
Expand Down