23andMe / Yamale

A schema and validator for YAML.
MIT License
679 stars 88 forks source link

Let users choose the file encoding #190

Open reconman opened 2 years ago

reconman commented 2 years ago

Fixes #189

I've added some type hints and comments to the user-facing functions. Wasn't sure about the type of validator, so it's still Any.

mechie commented 2 years ago

As an aside, I think this would be a breaking change--Windows-only users (or anyone with a supported non-utf-8 text encoding set as their locale) may be unwittingly, or intentionally, relying on this behavior.

mildebrandt commented 2 years ago

I agree @mechie , more comments in #189 .

reconman commented 2 years ago

I've changed it to the system default. Tested it with the value Chūnibyō demo Koi ga Shitai! in a YAML file. If I encode it as CP1252, it can be parsed on Windows. If I use UTF-8 instead, an exception is thrown.

Not really happy with copy-pasting the locale function call everywhere but I'm not a professional Python programmer, so there may be better ways.

mildebrandt commented 2 years ago

Thanks for your PR. Let me think a bit about the best way to handle this. Maybe instead of passing the encoding through several layers of functions, we could introduce a config mechanism.