Skip to content

default_env=True still conflicts default_config_files. #733

@ljw20180420

Description

@ljw20180420

default_env=True still conflicts default_config_files. This related to #465 and #466. The default_env_bug.py python file is

import jsonargparse

parser = jsonargparse.ArgumentParser(
    description="Test.",
    default_config_files=["default_env_bug.yaml"],
    default_env=True,
)
parser.add_argument("--val0")
subcommands = parser.add_subcommands()
cmd1 = jsonargparse.ArgumentParser()
cmd1.add_argument("--val1")
subcommands.add_subcommand("cmd1", cmd1)
cmd1_subcommands = cmd1.add_subcommands()
cmd2 = jsonargparse.ArgumentParser()
cmd2.add_argument("--val2")
cmd1_subcommands.add_subcommand("cmd2", cmd2)

args = parser.parse_args()
print(args)

Run

python default_env_bug.py

Output

usage: test.py [-h] [--val0 VAL0] {cmd1} ...
error: Validation failed: Subcommand 'cmd1' does not accept nested key 'cmd2.cmd2.val2'
  • jsonargparse version: 4.40.0
  • Python version: 3.11.13
  • How jsonargparse was installed: conda install conda-forge::jsonargparse
  • OS: ubuntu 24.04

The default_env_bug.yaml file is

val0: 0
cmd1:
  val1: 1
  cmd2:
    val2: 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions