From e4005505b9b7fd5fde1e45684c8746da920723fd Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 20 Feb 2021 14:11:36 -0700 Subject: [PATCH] Fixed incompatible use of constrained TypeVar in tempfile. (#5043) The TypeVar `_T` was being used as a type argument for `PathLike`, but `PathLike` requires that its type argument be constrained to `str` or `bytes`, and `_T` didn't provide any such constraint. The easy workaround is to use the TypeVar `AnyStr` instead. Co-authored-by: Eric Traut --- stdlib/tempfile.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index 7dd680321..a2ef7724b 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -13,8 +13,7 @@ tempdir: Optional[str] template: str _S = TypeVar("_S") -_T = TypeVar("_T") # for pytype, define typevar in same file as alias -_DirT = Union[_T, os.PathLike[_T]] +_DirT = Union[AnyStr, os.PathLike[AnyStr]] if sys.version_info >= (3, 8): @overload