Skip to content

argparse add_argument's type should allow Callable[[AnyStr], _T] #2988

@orinatic

Description

@orinatic

I have the following code:

    parser.add_argument("-L", "--loglevel", default="INFO",
                        type=string.upper,
                        help="Set log level output. (e.g., --log-level DEBUG)")

This fails to type-check because string.upper is Callable[[AnyStr], AnyStr], while the annotation for the type field is type: Union[Callable[[str], _T], FileType] = ....

I think it should be type: Union[Callable[[AnyStr], _T], FileType] = ...?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions