Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created May 8, 2024 19:48
Show Gist options
  • Save mypy-play/4e7d8753f580161c41e23a800ecf66b0 to your computer and use it in GitHub Desktop.
Save mypy-play/4e7d8753f580161c41e23a800ecf66b0 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
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