Skip to content

Conversation

@jackulau
Copy link
Contributor

Summary

  • Adds contextual hover for the in keyword in membership tests (shows __contains__ method signature)
  • Adds contextual hover for the in keyword in iteration contexts (shows iterable type)

Fixes #1926

Test plan

  • Added tests for in in membership test with custom __contains__
  • Added tests for in in for-loops
  • Added tests for in in list comprehensions
  • Added test for exact example from issue: [x for x in x if x in [1]]

Show contextual hover for `in` in both membership tests (displays
__contains__ signature) and iteration contexts (shows iterable type).
@meta-cla meta-cla bot added the cla signed label Dec 24, 2025
@github-actions

This comment has been minimized.

@github-actions
Copy link

Diff from mypy_primer, showing the effect of this PR on open source code:

typeshed-stats (https://github.com/AlexWaygood/typeshed-stats)
- ERROR src/typeshed_stats/gather.py:999:28-1002:10: `Pattern[Unknown] | @5300 | None` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR src/typeshed_stats/gather.py:999:28-1002:10: `Pattern[Unknown] | @7438 | None` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]

@meta-codesync
Copy link

meta-codesync bot commented Dec 26, 2025

@grievejia has imported this pull request. If you are a Meta employee, you can view this in D89812790.

@grievejia grievejia self-assigned this Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

show hover for in

3 participants