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 <erictr@microsoft.com>
This commit is contained in:
Eric Traut
2021-02-20 14:11:36 -07:00
committed by GitHub
parent c83d1ab0eb
commit e4005505b9

View File

@@ -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