I have this code which was accepted in a older version (0.6xx?) of mypy: ``` import pathlib import shutil from typing import Union def f(x: Union[str, pathlib.Path]): shutil.copyfile("bla", x) ``` But is not accepted by mypy 0.710: ``` error: Value of type variable "_AnyPath" of "copyfile" cannot be "Union[str, Path]" ``` How should I fix my type annotations? I tried this: ``` import os import shutil from typing import TypeVar _AnyPath = TypeVar("_AnyPath", str, os.PathLike) def f(x: _AnyPath): shutil.copyfile("bla", x) ``` And that seems to work. ---- I [asked this on StackOverflow](https://stackoverflow.com/questions/56736338/mypy-error-value-of-type-variable-anypath-of-copyfile-cannot-be-unionstr?noredirect=1#comment100038824_56736338) but it was suggested to open a "bug/missing feature issue" here.