[ty] Add return type inference edge case tests (#29325)
## Summary
This adds a few more tests for return type inference. Those are
scenarios that I came across while looking at the ecosystem impact of
the actual implementation
([astral-sh/ruff#29253](https://github.com/astral-sh/ruff/pull/29253)).