typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

ArgParse types don't allow using ArgParse's registry for the `type` keyword argument to `add_argument`

Open adamnovak opened this issue 2 years ago • 1 comments

ArgParse supports a registry feature, where you can name a function, and then pass that name instead of the actual function for the type of an argument added with add_argument.

But the types in typeshed say that strings are not allowed to be passed: https://github.com/python/typeshed/blob/4aae235cefd62ec417b92166d2bcf038cb8801e8/stdlib/argparse.pyi#L92C12-L92C12

This leads to type-checking errors when you try to use the registry for type.

adamnovak avatar Nov 16 '23 20:11 adamnovak

That applies to Action.type as well. A type alias _ActionType might be a good idea here. Any PRs welcome!

srittau avatar Nov 17 '23 11:11 srittau