Skip to content

pyyaml is no longer a required dependency - #970

Merged
mauvilsa merged 1 commit into
mainfrom
issue-229-pyyaml-optional
Sep 8, 2026
Merged

pyyaml is no longer a required dependency#970
mauvilsa merged 1 commit into
mainfrom
issue-229-pyyaml-optional

Conversation

@mauvilsa

@mauvilsa mauvilsa commented Sep 8, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Fixes #229

Makes pyyaml optional for v5, so pip install jsonargparse now installs with no required dependencies. Install the yaml extras (included in all) to get it.

Support for running without pyyaml already existed internally. This completes it:

  • Packaging: dependencies has been removed. The yaml extras is unchanged.
  • Fail early and clearly: a new import_pyyaml helper, following the existing import_jsonnet/import_toml_* pattern, raises PyYAML package is required by <importer> instead of a bare ModuleNotFoundError. The parser_mode setter now uses it, so parser_mode="yaml" fails at parser creation rather than at the first value that needs the loader, the same as parser_mode="jsonnet" already did.
  • Dump fallback: dump_using_format falls back to json instead of yaml when the parser mode has no dumper and pyyaml is not installed.
  • Testing: removed the without-pyyaml tox env and the steps that uninstalled pyyaml in the tests workflow. The no-extras tox env and the bare CI job now cover that case by construction.
  • Docs: readme, documentation, contributing and the v5 migration guide updated.

Also removes a stray parser.parser_mode = "yaml" in test_float_implicit_leading_zero that was defeating its own @parser_modes parametrization.

Without pyyaml, the default parser_mode and dump format is json. This is a breaking change for v5 with no deprecation warning, already noted in the migration guide.

Before submitting

  • Did you read the contributing guideline?
  • If you used a coding agent, did you fully understand and validate all generated code and ensure it follows the contributing guidelines?
  • Did you update the documentation? (readme and public docstrings)
  • Did you write unit tests such that there is 100% coverage on related code? (required for bug fixes and new features)
  • Did you verify that new and existing tests pass locally?
  • [n/a] If this is a bug fix, did you verify that the tests fail without the code fix?
  • Did you make sure that all changes preserve backward compatibility?
  • Did you update the CHANGELOG including a pull request link? (not for typos, docs, test updates, or minor internal changes/refactors)

@mauvilsa mauvilsa added the refactor Improvements to the quality of the code label Sep 8, 2026
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (deb48bd) to head (175d169).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #970   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         8729      8736    +7     
=========================================
+ Hits          8729      8736    +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

@mauvilsa
mauvilsa merged commit f3655d4 into main Sep 8, 2026
32 checks passed
@mauvilsa
mauvilsa deleted the issue-229-pyyaml-optional branch September 8, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Improvements to the quality of the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make pyyaml an optional dependency

1 participant