Skip to content

Issue with Root Args and config file #232

@efanibi25

Description

@efanibi25

🐛 Bug report

An error
jsonargparse.util.ParserError: Problem in default config file "/home/main/Tools/.config/config.yaml" :: Configuration check failed :: No action for destination key "prepare.output" to check its value.
is raised when trying to parse args

To reproduce

parser = ArgumentParser(default_config_files=[os.path.join('.config/config.yaml')])
    parser.add_argument('-c','--config', action=ActionConfigFile,help="override config file")  
    parser.add_argument("-o","--output",help="Path to Dir",required=True)
    prepare = ArgumentParser(description="Prepare file to be uploaded")
    prepare.add_argument('-m','--media',help="Directory to retrive media files",required=True)
  subcommands = parser.add_subcommands()
    subcommands.add_subcommand('prepare',prepare, help="prepare mediafile for upload")

root argument must have required=True
root argument must also come before any group arguments.

Also Note: I have been able to fix this by setting root args to be the last argument

It strange because it also can parses correctly if I set required=False

Expected behavior

Parse arguments

Environment

  • jsonargparse version 4.19.0
  • Python version 3.8
  • How jsonargparse was installed (e.g. `pip install jsonargparse):
  • OS Linux

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