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

Cog is failing with round_trip_load_all() YAML error #2219

Closed
simonw opened this issue Dec 19, 2023 · 3 comments
Closed

Cog is failing with round_trip_load_all() YAML error #2219

simonw opened this issue Dec 19, 2023 · 3 comments
Labels

Comments

@simonw
Copy link
Owner

simonw commented Dec 19, 2023

https://github.com/simonw/datasette/actions/runs/7265948406/job/19796712354

Run cog --check docs/*.rst
Traceback (most recent call last):
Checking docs/authentication.rst
  File "docs/authentication.rst", line 220, in <module>
    config_example(cog, """
  File "/home/runner/work/datasette/datasette/docs/metadata_doc.py", line 31, in config_example
    data = round_trip_load(input)
  File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/ruamel/yaml/main.py", line 1127, in round_trip_load
    error_deprecation('round_trip_load_all', 'load')
  File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/ruamel/yaml/main.py", line 1039, in error_deprecation
    raise AttributeError(s, name=None)
AttributeError: 
"round_trip_load_all()" has been removed, use

  yaml = YAML()
  yaml.load(...)

instead of file "/home/runner/work/datasette/datasette/docs/metadata_doc.py", line 31

        data = round_trip_load(input)
@simonw
Copy link
Owner Author

simonw commented Dec 19, 2023

Code at fault:

if yaml:
# dedent it first
yaml = textwrap.dedent(yaml).strip()
# round_trip_load to preserve key order:
data = round_trip_load(yaml)
output_yaml = yaml

@simonw
Copy link
Owner Author

simonw commented Dec 19, 2023

I can duplicate the bug locally by upgrading ruamel.yaml:

$ pip freeze | grep yaml
ruamel.yaml==0.17.32
ruamel.yaml.clib==0.2.7
$ pip install -U ruamel.yaml
Requirement already satisfied: ruamel.yaml in /Users/simon/.local/share/virtualenvs/datasette-AWNrQs95/lib/python3.10/site-packages (0.17.32)
Collecting ruamel.yaml
  Downloading ruamel.yaml-0.18.5-py3-none-any.whl (116 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 116.4/116.4 kB 2.9 MB/s eta 0:00:00
Requirement already satisfied: ruamel.yaml.clib>=0.2.7 in /Users/simon/.local/share/virtualenvs/datasette-AWNrQs95/lib/python3.10/site-packages (from ruamel.yaml) (0.2.7)
Installing collected packages: ruamel.yaml
  Attempting uninstall: ruamel.yaml
    Found existing installation: ruamel.yaml 0.17.32
    Uninstalling ruamel.yaml-0.17.32:
      Successfully uninstalled ruamel.yaml-0.17.32
Successfully installed ruamel.yaml-0.18.5

There's a note about that here: https://yaml.readthedocs.io/en/latest/#changelog

  • the functions scan, parse, compose, load, emit, serialize, dump and their variants (_all, safe_, round_trip_, etc) have been deprecated (the same named methods on YAML() instances are, of course, still there.

@simonw simonw changed the title Cog is failing Cog is failing with round_trip_load_all() YAML error Dec 19, 2023
@simonw
Copy link
Owner Author

simonw commented Dec 19, 2023

Fixed.

@simonw simonw closed this as completed Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant