Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Thanks, I'll consider it for the future!

Python has worked fairly well for us so far though, we have tests that would detect invalid syntax, and importing a Python file is easier than parsing and doing the error handling on YAML/JSON.



Shouldn't be much more than a 3-4 lines of code to import from YAML with this library, especially if you have a simple schema:

e.g.

    import strictyaml as sy

    MY_TRANSLATIONS_DICT = sy.load(
        Path("translations.yml").text(),
        sy.MapPattern(sy.Str(), sy.Map({"French": sy.Str(), "German": sy.Str()})),
    ).data

    translations.yml:

    Hello:
      French: Bonjour
      German: Guten Tag
    Goodbye:
      French: Au revoir
      German: Auf wiedersehen
    
It would negate the need for most of those tests checking for invalid data, too (the above would raise an exception instantly if there is a YAML syntax error or if the data doesn't match the schema).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: