From 9a76b13127ffa8365431dcc105fc111cdd267e7e Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 25 Mar 2022 10:18:09 +0100 Subject: [PATCH] Add _typeshed.Incomplete (#7535) Closes: #5613 --- stdlib/_typeshed/__init__.pyi | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index ee3aa766d..b6c7e0762 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -8,7 +8,7 @@ import mmap import sys from os import PathLike from typing import AbstractSet, Any, Awaitable, Container, Generic, Iterable, Protocol, TypeVar -from typing_extensions import Final, Literal, final +from typing_extensions import Final, Literal, TypeAlias, final _KT = TypeVar("_KT") _KT_co = TypeVar("_KT_co", covariant=True) @@ -23,6 +23,13 @@ _T_contra = TypeVar("_T_contra", contravariant=True) # def __enter__(self: Self) -> Self: ... Self = TypeVar("Self") # noqa Y001 +# For partially known annotations. Usually, fields where type annotations +# haven't been added are left unannotated, but in some situations this +# isn't possible or a type is already partially known. In cases like these, +# use Incomplete instead of Any as a marker. For example, use +# "Incomplete | None" instead of "Any | None". +Incomplete: TypeAlias = Any + # stable class IdentityFunction(Protocol): def __call__(self, __x: _T) -> _T: ...