Created
January 24, 2026 18:56
-
-
Save mypy-play/9c7b83d3104aa414bd2a9eeb6c3e2974 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import annotations | |
| from typing import overload, Iterator | |
| class Foo: | |
| @overload | |
| def method(self: Bar) -> Iterator[Bar]: ... | |
| @overload | |
| def method(self: Foo) -> Iterator[Foo]: ... | |
| def method(self) -> Iterator[Foo] | Iterator[Bar]: | |
| raise NotImplementedError | |
| class Bar: ... | |
| class Baz(Foo): | |
| def method(self) -> Iterator[Foo]: | |
| raise NotImplementedError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment