This doesn't seem to work:
from typing import NewType
MyStr = NewType("MyStr", str)
x = MyStr("Hello World")
isinstance(x, MyStr)
I don't even get False
, but TypeError: isinstance() arg 2 must be a type or tuple of types
because MyStr
is a function and isinstance
wants one or more type
.
Even assert type(x) == MyStr
or is MyStr
fails.
What am I doing wrong?