Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New lines after comment line causes NotImplementedError #198

Open
JureMalovrh opened this issue Jun 2, 2023 · 0 comments
Open

New lines after comment line causes NotImplementedError #198

JureMalovrh opened this issue Jun 2, 2023 · 0 comments

Comments

@JureMalovrh
Copy link

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)
@JureMalovrh JureMalovrh changed the title New line after comment line causes NotImplementedError New lines after comment line causes NotImplementedError Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant