mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-06 03:56:54 +00:00
Merge 9f6eb9cd1b into f1dff44d3a
This commit is contained in:
commit
ef568bda94
3 changed files with 11 additions and 1 deletions
|
|
@ -63,7 +63,13 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||||
with open(filename, encoding='UTF-8') as f:
|
with open(filename, encoding='UTF-8') as f:
|
||||||
load_fn(f)
|
load_fn(f)
|
||||||
except ruamel.yaml.YAMLError as exc:
|
except ruamel.yaml.YAMLError as exc:
|
||||||
print(exc)
|
print(f'{filename}: Failed to yaml parse ({exc})')
|
||||||
|
retval = 1
|
||||||
|
except UnicodeDecodeError as exc:
|
||||||
|
print(
|
||||||
|
f'{filename}: Failed to read file due to encoding error '
|
||||||
|
f'({exc})',
|
||||||
|
)
|
||||||
retval = 1
|
retval = 1
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
|
||||||
3
testing/resources/bad_encoding_yaml.yaml
Normal file
3
testing/resources/bad_encoding_yaml.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
variables:
|
||||||
|
- name: CopyRights
|
||||||
|
value: "Copyright © $(date:YYYY)"
|
||||||
|
|
@ -9,6 +9,7 @@ from testing.util import get_resource_path
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
('filename', 'expected_retval'), (
|
('filename', 'expected_retval'), (
|
||||||
('bad_yaml.notyaml', 1),
|
('bad_yaml.notyaml', 1),
|
||||||
|
('bad_encoding_yaml.yaml', 1),
|
||||||
('ok_yaml.yaml', 0),
|
('ok_yaml.yaml', 0),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue