Skip to content

RootModel[str] cannot be parsed in cli with cli_enforce_required. #676

@plusls

Description

@plusls

like #342


def test_cli_root_model():
    """Testing to pass string directly to root model by cli."""
    class Foo(RootModel[str]):
        root: str

    class Settings(BaseSettings, cli_enforce_required=True):
        foo: Foo
        plain: str

    TEST_STR = 'hello world'
    assert CliApp.run(Settings, cli_args=['--foo', TEST_STR, '--plain', TEST_STR]).model_dump() ==  {'foo': TEST_STR, 'plain': TEST_STR}


will cause system exit

Metadata

Metadata

Assignees

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