Created
March 9, 2026 19:51
-
-
Save mypy-play/900109d4edbe049f7c3a36abf7ea98fb 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 typing import Self, reveal_type | |
| class NodeA: | |
| def __init__(self: Self) -> None: | |
| reveal_type(self) # Self`0 | |
| self.myself: Self = self # ✅️ | |
| class NodeB: | |
| def __init__(self) -> None: | |
| reveal_type(self) # __main__.NodeB | |
| self.myself: Self = self # ❌️ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment