Created
May 8, 2024 19:48
-
-
Save mypy-play/4e7d8753f580161c41e23a800ecf66b0 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 | |
Weight = NewType("Weight", int) | |
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