Skip to content

New lines after comment line causes NotImplementedError #198

Open
@JureMalovrh

Description

Hi,

first - thanks for the great library!

Our team is trying to parse GitHub action YAML using strictyaml and we have reached an issue. If we use the inline comments in a file the YAML load fails with NotImplementedError

Minimal reproduction case:

from strictyaml import load, Map, Str, Int, Seq, YAMLError
yml_str = """
name: Action

on: # yamllint disable-line rule:truth
   push

"""
load(yml_str)

This will cause following issue:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[6], line 9
      1 from strictyaml import load, Map, Str, Int, Seq, YAMLError
      2 yml_str = """
      3 name: Action
      4
   (...)
      7
      8 """
----> 9 load(yml_str)

... omitted for readability

File ~/.local/share/virtualenvs/rtZ2jilx/lib/python3.10/site-packages/strictyaml/ruamel/tokens.py:86, in Token.move_comment(self, target, empty)
     84     return self
     85 if c[0] and tc[0] or c[1] and tc[1]:
---> 86     raise NotImplementedError("overlap in comment %r %r" % (c, tc))
     87 if c[0]:
     88     tc[0] = c[0]

The following case parses successfully:

from strictyaml import load, Map, Str, Int, Seq, YAMLError
yml_str = """
name: Action

on: # yamllint disable-line rule:truth
  push
"""
load(yml_str)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions