-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
argparse.ArgumentParser.parse_args() overload misfire #2641
Comments
The argparse documentation gives an explicit example of a non- |
OK, but can we at least do something so that mypy understands that
and this gives an error on the Maybe adding another overload with an explicit |
Explicit |
Hm, I'm not so sure. Here's a simple test program:
This currently gives
But when I insert
in the list of (We'd also need an extra overload for |
Huh, learned something new today. That's definitely useful and in that case just overloading |
Union math kicks in soon on purpose, mypy now works much better with overloads :-) |
I had some code calling
parse_args(args, ns)
where the type ofns
wasOptional[Namespace
. It then deduced that the return type was alsoOptional[Namespace]
. I think this is a mistake -- I don't thinkparse_args()
ever returnsNone
. Perhaps_N
should be constrained bybound='Namespace'
?The text was updated successfully, but these errors were encountered: