title: PyYAML automatically converting certain keys to boolean values
body: <p>I've been working with a the <code>PyYAML</code> parser for a few months now to convert file types as part of a data pipeline. I've found the parser to be quite idiosyncratic at times and it seems that today I've stumbled on another strange behavior. The file I'm currently converting contains the following section:</p>
  
  <pre><code>off:
      yes: "Flavor text for yes"
      no: "Flavor text for no"
  </code></pre>
  
  <p>I keep a list of the current nesting in the dictionary so that I can construct a flat document, but save the nesting to convert back to YAML later on. I got a <code>TypeError</code> saying I was trying to concatenate a <code>str</code> and <code>bool</code> type together. I investigated and found that <code>PyYaml</code> is actually taking my section of text above and converting it to the following:</p>
  
  <pre><code>with open(filename, "r") as f:
      data = yaml.load(f.read())
  print data
  
  &gt;&gt; {False: {True: "Flavor text for yes", False: "Flavor text for no}}
  </code></pre>
  
  <p>I did a quick check and found that <code>PyYAML</code> was doing this for <code>yes</code>, <code>no</code>, <code>true</code>, <code>false</code>, <code>on</code>, <code>off</code>. It only does this conversion if the keys are unquoted. Quoted values and keys will be passed fine. Looking for solutions, I found this behavior documented <a href="https://docs.saltstack.com/en/latest/topics/troubleshooting/yaml_idiosyncrasies.html" rel="noreferrer">here</a>. </p>
  
  <p>Although it might be helpful to others to know that quoting the keys will stop <code>PyYAML</code> from doing this, I don't have this option as I am not the author of these files and have written my code to touch the data as little as possible. </p>
  
  <p>Is there a workaround for this issue or a way to override the default conversion behavior in <code>PyYAML</code>? </p>