-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Set difference unexpectedly permissive #1840
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
But if we did that, wouldn't mypy just infer |
In context, I had the function's return type as |
Yeah, but the point is that the set operation itself wouldn't get the error
-- and in some cases the error would come much later and surprise people.
|
Better a surprising type error (easily diagnosed with reveal_type) than shipping a no-op to production, as I did before submitting this issue. :) |
Changing typeshed/stdlib/3/builtins.pyi Line 717 in 9ee4582
makes mypy complain about the last line in the example above. This seems reasonable to me. (Similar to the other set operations.) This is also in line with the other container types. For example, we only ordering comparisons between lists of the same type, but for sets we allow any set. This is inconsistent. |
Mypy passes accepts the following snippet, even though the set subtraction is guaranteed to be a no-op.
Would it make sense to require
Set[T]
for both arguments to a difference operation?The text was updated successfully, but these errors were encountered: