Skip to content

Deprecate instantiation of subclass specs in Any and missing --print_%s deprecation warning - #955

Merged
mauvilsa merged 2 commits into
mainfrom
deprecations
Aug 14, 2026
Merged

Deprecate instantiation of subclass specs in Any and missing --print_%s deprecation warning#955
mauvilsa merged 2 commits into
mainfrom
deprecations

Conversation

@mauvilsa

Copy link
Copy Markdown
Owner

What does this PR do?

Two deprecations for v5.0.0:

Instantiation of subclass specs in Any

When a value for a type that accepts anything (Any or Unvalidated<...>) is a valid
subclass spec, instantiate_classes currently builds the class. This is deprecated: from
v5.0.0 the subclass spec will be kept as is, leaving it to the code that receives it to
decide whether to instantiate. Instantiating is a security risk, since it means a config
can instantiate any class.

A new instantiate_subclass_spec_in_any setting in set_parsing_settings allows opting
into the future behavior now (False, silencing the warning) or keeping the current one
(True, discouraged). The setting defaults to None, which behaves as True and emits
the deprecation warning; in v5.0.0 the default becomes False and the deprecated path is
removed.

--print_config to --print_%s

The name change announced in v4.35.0 never emitted a warning. One is now raised (under
JSONARGPARSE_DEPRECATION_WARNINGS=all) when the config argument is not named config,
so the print config argument name will change in v5.0.0.

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 Aug 14, 2026
@mauvilsa
mauvilsa deployed to sonarcloud August 14, 2026 10:09 — with GitHub Actions Active
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (553c8b0) to head (0b68236).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #955   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         8444      8464   +20     
=========================================
+ Hits          8444      8464   +20     

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

@sonarqubecloud

Copy link
Copy Markdown

@mauvilsa
mauvilsa merged commit 2025e7b into main Aug 14, 2026
32 checks passed
@mauvilsa
mauvilsa deleted the deprecations branch August 14, 2026 10:12
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.

1 participant