The thing is you can't parse json and yaml from either a file-like or a string object in one line of Python. To achieve that you end up writing at least 3-4 lines of checking logic each time, plus some try/catch blocks. I had to parse yaml or json in about 20 different places in our system and it was just not useful to repeat the same code everywhere. Now these 20 places are now all using this markup function, with the requirement met that the respective calling code is not more complex than before but (fail) safer and more flexible (support json and yaml at the choice of the end user).