x : int = 3 print('x =',x, type(x)) x = "forty" # type error if run through mypy or pylance print('x =',x, type(x)) y : int|str = 3 # y can be either of two types y += 3 # type error if run through mypy or pylance: works for int but not str if isinstance(y, int): # check if it is one of those types; enables type-specific operations y += 3 else: y += ' three'