-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
set.union not working correctly #2013
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
Comments
Worth noting that this works:
|
Thanks for the report! I think this is a case where our type inference within a statement/expression is a little too dependent on specific rules and consequently only able to reason through N layers of indirection but not N+1. We've talked about this before (/cc especially @ddfisher), but I'm not sure we have an issue squarely directed at it -- #1055 appears to be closest. I'd certainly like to fix this kind of situation, preferably in a way that involves reducing the number of special cases, but I don't think we yet know precisely how to do that. For now, the workaround in your follow-up comment is the recommended approach -- fortunately it's usually not particularly cumbersome. |
Note that this:
works fine. This may be a nice workaround in some situations. |
Can't reproduce on 0.940 https://mypy-play.net/?mypy=0.940&python=3.10&flags=strict&gist=40e9a86b91e4e4727bdf743b544847dd |
Uh oh!
There was an error while loading. Please reload this page.
Code:
a = set().union(*[[1],[2],[3]]) # type: Set[int]
Expected:This should work fine
Result:
I'm fairly new to mypy, so please let me know if this is user error.
The text was updated successfully, but these errors were encountered: