janezd / trubar

Utility for translation of strings and f-strings in Python files
MIT License
3 stars 2 forks source link

Consider replacing PyYAML with strictyaml #31

Closed janezd closed 1 year ago

janezd commented 1 year ago

Trubar uses a very limited subset of Yaml, so the parser should be as simple as possible, if this is beneficial in any way.

PyYAML's error messages are difficult to understand. I hope strictyaml's are better, because it understands a limited set of YAML.

It should also be safer, e.g., avoids the Norway problem etc.

janezd commented 1 year ago

Furthermore, trubar's schema is recursive. MsgDict = Dict[str, Union["MsgDict", str, bool, None]] can be represented in strictyaml using the following hack,

yaml_schema = MapPattern(Str(), EmptyNone() | NullNone() | Bool() | Str() | Validator())
yaml_schema._value_validator._validator_b = yaml_schema

but we obviously don't want to do this.

Continued in #41.