void () { runWithLanguageLevel(LanguageLevel.PYTHON39, () -> { doTestByText(""" from typing import Union from __future__ import annotations class A: pass assert isinstance(A(), <error descr="'Union' cannot be used with instance and class checks">Union</error>) B = Union assert issubclass(A, <error descr="'Union' cannot be used with instance and class checks">B</error>) assert isinstance(A(), <error descr="'Union' cannot be used with instance and class checks">Union[int, str]</error>) assert issubclass(A, <error descr="'Union' cannot be used with instance and class checks">B[int, str]</error>) C = B[int, str] assert issubclass(A, <error descr="'Union' cannot be used with instance and class checks">C</error>) assert isinstance(A(), <error descr="'Union' cannot be used with instance and class checks">Union[str, Union[str, Union[list, dict]]]</error>) assert isinstance(A(), <error descr="'Union' cannot be used with instance and class checks">Union[str, Union[str, Union[list[int], dict]]]</error>) assert isinstance(A(), <error descr="Python version 3.9 does not allow writing union types as X | Y">int | str</error>) assert isinstance(A(), <error descr="Python version 3.9 does not allow writing union types as X | Y">int | list[str]</error>) assert issubclass(A, <error descr="Python version 3.9 does not allow writing union types as X | Y">int | str</error>) assert issubclass(A, <error descr="Python version 3.9 does not allow writing union types as X | Y">int | list[str]</error>)"""); }); }