Skip to content

Change default parser mode to json - #997

Merged
mauvilsa merged 1 commit into
mainfrom
parser-mode-json-default
Oct 2, 2026
Merged

mauvilsa merged 1 commit into
mainfrom
parser-mode-json-default

Conversation

@mauvilsa

@mauvilsa mauvilsa commented Oct 2, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

  • Breaking: parser_mode now defaults to json instead of yaml, so behavior no longer depends on whether pyyaml happens to be installed (it became optional in pyyaml is no longer a required dependency #970). YAML configs and YAML-syntax values, e.g. --list=[a, b] or --flag=yes, now fail unless parser_mode="yaml" is given.
  • New parser_mode setting in set_parsing_settings and JSONARGPARSE_PARSER_MODE environment variable, so users can restore YAML globally without changing every parser.
  • The jsonnet parser mode no longer silently accepts YAML.
  • The v5 migration guide explains the change and how to keep YAML, including parser_mode="yaml", which also works in v4.

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 enhancement New feature or request refactor Improvements to the quality of the code labels Oct 2, 2026
Comment thread jsonargparse_tests/test_loaders_dumpers.py Dismissed
@mauvilsa
mauvilsa deployed to sonarcloud October 2, 2026 06:25 — with GitHub Actions Active
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (632b1dd) to head (4119ba3).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #997   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         9647      9657   +10     
=========================================
+ Hits          9647      9657   +10     

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

@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High risk] Changes the default parser mode from YAML to JSON.

The PR appears safe to merge, with a non-blocking gap in test coverage for default-JSON parsing.

Findings

  1. P2 Default JSON behavior lacks coverage ▶

Summary

Changes the default parser mode to JSON, adds a global setting and environment override, and makes basic-type and Jsonnet loading follow the selected mode.

  • Updates documentation and the v5 migration guide for the breaking default change.
  • Adds mode-specific tests, although the suite-wide YAML override leaves the new default insufficiently exercised.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Parser has explicit mode?] -->|Yes| B[Use explicit mode]
  A -->|No| C{Environment override?}
  C -->|Yes| D[Use JSONARGPARSE_PARSER_MODE]
  C -->|No| E[Use global setting: JSON by default]
  B --> F[Load values and configs]
  D --> F
  E --> F
Loading

Reviews (1) · Last reviewed commit: "Change default parser mode to json"

Comment thread jsonargparse_tests/conftest.py
@mauvilsa
mauvilsa merged commit d2350da into main Oct 2, 2026
33 checks passed
@mauvilsa
mauvilsa deleted the parser-mode-json-default branch October 2, 2026 06:45

This branch was successfully deployed

1 active deployment
sonarcloud — 4119ba32 Deployed Oct 2, 2026 by mauvilsa via sonarcloud #933
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request refactor Improvements to the quality of the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants