Created
May 8, 2024 19:55
-
-
Save mypy-play/6f8c8cd5e9d0cb43b92270894b7305e8 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains 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 NewType, TYPE_CHECKING | |
class Weight(int): | |
if TYPE_CHECKING: | |
def __iadd__(self, x: object): ... | |
x = Weight(10) | |
y = Weight(2) | |
# This is what I want to do | |
x += y | |
# This is what I have to do | |
x = Weight(x + y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment