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.
This commit is contained in:
Hood Chatham
2023-07-13 02:15:15 -07:00
committed by GitHub
parent f2ee9e9368
commit ad3648dd4e

View File

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