title: YAML File not loading with nested values
body: <p>I am writing a YAML parser in python using ruamel.yaml
  Reason for ruamel.yaml is it maintains comments which are key!</p>
  <p>I know the issue is caused with the YAML file, and I am not sure on how to overcome this issue, or what a potential modification is. I have tried a few variations of indentation, but have struck out.</p>
  <p>Keeping it simple, passing in source and trying to load it.</p>
  <p>Code:</p>
  <pre><code>import os
  import os.path
  import ruamel.yaml
  from ruamel.yaml import YAML
  
  def main():
      source = &quot;my_yaml.yml&quot;
      # Check if the source fil is valid yaml
      try:
          yaml = ruamel.yaml.YAML()
          with open(source) as fp:
              # data is the file data and will be used down the line
              data = yaml.load(fp)
  
          if data is None:
              data = {}
          return data
      except:
          print(&quot;Yaml file is not valid. Please check the source.&quot;)
          return 1
  
  if __name__ == &quot;__main__&quot;:
      out = main()
  </code></pre>
  <p>YAML that works:</p>
  <pre><code>d1: &quot;key1&quot;
  d2: &quot;key2&quot;
  d3: 
    d3_nest1: &quot;key3&quot;
    d3_nest2: &quot;key4&quot;
  </code></pre>
  <p>YAML that does not work:</p>
  <pre><code>d1: &quot;key1&quot;
  d2: &quot;key2&quot;
  d3: 
    d3_nest1: &quot;key3&quot;
    d3_nest2: &quot;key4&quot;
    # this next item breaks my yaml
    - d3_nest3: &quot;key6&quot;
    d3_nest4: &quot;key7&quot;
  </code></pre>
  <p>Other Variations of YAML:</p>
  <pre><code>d1: &quot;key1&quot;
  d2: &quot;key2&quot;
  d3: 
      d3_nest1: &quot;key4&quot;
      d3_nest2: &quot;key5&quot;
  # this next item breaks my yaml
  - d3_nest3: &quot;key6&quot;
      d3_nest4: &quot;key7&quot;
  
  d1: &quot;key1&quot;
  d2: &quot;key2&quot;
  d3: 
      d3_nest1: &quot;key4&quot;
      d3_nest2: &quot;key5&quot;
  # this next item breaks my yaml
      - d3_nest3: &quot;key6&quot;
          d3_nest4: &quot;key7&quot;
  </code></pre>