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

Always pass a Loader argument to yaml.load #274

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

sbesson
Copy link
Member

@sbesson sbesson commented Oct 14, 2021

Since PyYAML 5.1, calling yaml.load() without specifying a Loader argument is deprecated. With the release of PyYAML 6.0 yesterday, the Loader is now a mandatory positional argument.

This causes scc commands loading YAML configurations e.g. merge --repository-config (see https://merge-ci.openmicroscopy.org/jenkins/job/BIOFORMATS-push/1006/console ) or the newly introduced bump-conda-version to fail on newly created environments - see also yaml/pyyaml#576

This PR adjusts all usages of yaml.load() to pass Loader=yaml.FullLoader which is equivalent to the former call. This should make the library compatible with both PyYAML 5.x and PyYAML 6.x. The alternative would be to cap PyYAML to 5.x but this feels like a minimal change to maintain compatibility between both lines. The only open question is around the loader to use. feb2c22 uses the FullLoader which is identical to the previous call but there might be a case for tightening it to SafeLoader.

To test this PR:

  • create a new Python virtual environment and run /path/to/venv/bin/pip install scc - this should install PyYAML 6.0
  • using https://github.com/ome/bio-formats-build, run the following command
    /path/to/venv/bin/scc merge --info master --repository-config=scripts/repositories.yml 
    
    this should fail with the same error as indicated above
  • checkout this branch and re-install scc in the same virtual environment /path/to/venv/bin/pip install . Running the same command as above should now execute the command as expected

This should be compatible with both PyYAML 5.x and the newly released 6.0
@sbesson
Copy link
Member Author

sbesson commented Oct 15, 2021

Merging and releasing to assess the impact on the rest of the CI pipeline.

@sbesson sbesson merged commit 47407f3 into ome:master Oct 15, 2021
@sbesson sbesson deleted the pyyaml_loader_6.0 branch October 15, 2021 08:12
@sbesson
Copy link
Member Author

sbesson commented Oct 16, 2021

1a54999 pushed (and released) to fix a regression in the bump-version-conda. I had overlooked the fact that ruamel.yaml introduced in #273 is a complete alternative topyyaml. There is likely a case for unifying.

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

Successfully merging this pull request may close these issues.

1 participant