Make inspect.getblock more ergonomic for common input types (#10920)

This commit is contained in:
Viicos
2023-10-25 13:58:11 +02:00
committed by GitHub
parent 5c775a3502
commit 78fba20110

View File

@@ -294,6 +294,14 @@ _SourceObjectType: TypeAlias = (
def findsource(object: _SourceObjectType) -> tuple[list[str], int]: ...
def getabsfile(object: _SourceObjectType, _filename: str | None = None) -> str: ...
# Special-case the two most common input types here
# to avoid the annoyingly vague `Sequence[str]` return type
@overload
def getblock(lines: list[str]) -> list[str]: ...
@overload
def getblock(lines: tuple[str, ...]) -> tuple[str, ...]: ...
@overload
def getblock(lines: Sequence[str]) -> Sequence[str]: ...
def getdoc(object: object) -> str | None: ...
def getcomments(object: object) -> str | None: ...