From ad3648dd4e430e2f49b60e1e75ce5b181eed3ba3 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 13 Jul 2023 02:15:15 -0700 Subject: [PATCH] Fix type of linecache.cache (#10447) An entry of linecache.cache is either a lazy entry or a full entry. The full entries are typed correctly but the lazy entry is supposed to be a one-tuple consisting of a function that takes zero arguments and returns either a string or None. --- stdlib/linecache.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/linecache.pyi b/stdlib/linecache.pyi index 8e317dd38..2e050e13b 100644 --- a/stdlib/linecache.pyi +++ b/stdlib/linecache.pyi @@ -1,5 +1,6 @@ import sys -from typing import Any, Protocol +from collections.abc import Callable +from typing import Any from typing_extensions import TypeAlias if sys.version_info >= (3, 9): @@ -10,8 +11,7 @@ else: _ModuleGlobals: TypeAlias = dict[str, Any] _ModuleMetadata: TypeAlias = tuple[int, float | None, list[str], str] -class _SourceLoader(Protocol): - def __call__(self) -> str | None: ... +_SourceLoader: TypeAlias = tuple[Callable[[], str | None]] cache: dict[str, _SourceLoader | _ModuleMetadata] # undocumented