Skip to content

Type Support for argparse.Namespace() #200

@jude253

Description

@jude253

Hello,

I hope you are well. I really like Pydantic, and I've found it makes it much easier and also neater to work with classes in python.

Today, I tried to use it to put the arguments parsed from the command line with argparse as an attribute in class to use composition. The exact type name is argparse.Namespace. Because this wasn't able to work, I just converted the arguments to a default dictionary type and used that with pedantic.

This works, but I think it would be much nicer to have the argparse type be able to work work pydantic classes by default, this way I can use the built-in functionality of that, rather than just using dictionary keys to get the arguments.

Would it be possible to add this?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions