Skip to content
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

Fixes 'in' operator rejected with union type operand #9571

Closed
wants to merge 5 commits into from

Conversation

LiuYuHui
Copy link
Contributor

Description

Fixes #4954

Copy link
Collaborator

@msullivan msullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

This looks like it silences some issues:

w: Union[Container[str], int]
'x' in v

no longer produces an error.

I would try to avoid too much manual fiddling with local_errors. Maybe the thing to do is to extract most of the logic to a helper function and have it recurse in in the UnionType case.

@LiuYuHui
Copy link
Contributor Author

@msullivan It seems like that this fix doesn't silence the case you mention, my thought is that split the original union type into two parts, one is that have __contains__, the other one is that don't have __contains__, and the next part will check if this one have 'in' operator. Do you know other way to find if the type have __contains__? It is the only way (use local_errors) I know.

@LiuYuHui LiuYuHui closed this Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'in' operator rejected with union right operand
2 participants