mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Make inspect.getblock more ergonomic for common input types (#10920)
This commit is contained in:
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user