Add `Message.python_brace_format` by tomasr8 · Pull Request #1169 · python-babel/babel

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, there is a subtle difference. Consider the string {} {. If you try to format it, you'll get a ValueError because of the unclosed second brace which makes it invalid. However, _has_python_brace_format will return True because the any short-circuits before the parser gets to the invalid brace.

This might be a bit surprising. Perhaps we should only return True if the whole string is valid?