mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-10-07 12:44:33 +08:00
Make inspect.getblock more ergonomic for common input types (#10920)
This commit is contained in:
1 parent
5c775a3502
commit
78fba20110
1 file changed
+8
@@ -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