I'm going to revert to #17344 since fixing the logic may be non-trivial, and there is also another related bug (#17841).
The original PR can be submitted again with a fix that uses the same logic we use for == narrowing. If there is desire to support more narrowing use cases, this should be addressed in a separate issue/PR, and both == and "in" narrowing should remain consistent.
Activity
Revert "Narrow based on collection containment (#17344)"
Revert "Narrow based on collection containment (python#17344)" (pytho…
Add regression test cases (#17869)
Rework narrowing logic for equality and identity (#20492)
Narrow types based on collection containment (#20602)