[Python] use pydantic settings cli to parse partial json from file

Discussão em 'Python' iniciado por Stack, Fevereiro 24, 2025.

  1. Stack

    Stack Membro Participativo

    I want to use pydantic-settings for the following scenario: I have two options to write CLI parameters to my application, either by providing a json file or a command. E.g.

    myapp --config myconfig.json --logger DEBUG


    The command line arguments should override the definitions in the json file.

    My json file is nested.

    Is it possible?

    I thought of pre-parsing the args, reading the file with pydantic, and then make it the "default" for the cli, but I couldn't find a way to do it.

    Continue reading...

Compartilhe esta Página