From 21358713561c810dc6368f4a5d92d6cb7920bee7 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Mon, 23 Jan 2023 17:40:15 +0200 Subject: [PATCH] PY-57541 PY-53896 Add missing AnyStr_co to partially updated Typeshed Its absence made Py3TypeCheckerInspectionTest.testPathlibPathMatchingOsPathLike fail as os.PathLike protocol wasn't considered generic. Once the changes for generics are in the upstream, we will be able to update the Typeshed fully at long last. GitOrigin-RevId: 1333cc19bff15e328996c57362124a7fdb5ab057 --- python/helpers/typeshed/stdlib/_typeshed/__init__.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/helpers/typeshed/stdlib/_typeshed/__init__.pyi b/python/helpers/typeshed/stdlib/_typeshed/__init__.pyi index a3f56899247b..1eec268d5c31 100644 --- a/python/helpers/typeshed/stdlib/_typeshed/__init__.pyi +++ b/python/helpers/typeshed/stdlib/_typeshed/__init__.pyi @@ -23,6 +23,9 @@ _T_contra = TypeVar("_T_contra", contravariant=True) # def __enter__(self: Self) -> Self: ... Self = TypeVar("Self") # noqa Y001 +# covariant version of typing.AnyStr, useful for protocols +AnyStr_co = TypeVar("AnyStr_co", str, bytes, covariant=True) # noqa: Y001 + # stable class IdentityFunction(Protocol): def __call__(self, __x: _T) -> _T: ...