mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
inspect: use more specific arg type for some source retrieve functions (#3155)
This commit is contained in:
committed by
Sebastian Rittau
parent
bd2d0fcc85
commit
c6cbe4da66
@@ -1,4 +1,4 @@
|
||||
from types import CodeType, TracebackType, FrameType, ModuleType
|
||||
from types import CodeType, TracebackType, FrameType, FunctionType, MethodType, ModuleType
|
||||
from typing import Any, Dict, Callable, List, NamedTuple, Optional, Sequence, Tuple, Type, Union
|
||||
|
||||
# Types and members
|
||||
@@ -52,20 +52,19 @@ def isgetsetdescriptor(object: object) -> bool: ...
|
||||
def ismemberdescriptor(object: object) -> bool: ...
|
||||
|
||||
# Retrieving source code
|
||||
def findsource(object: object) -> Tuple[List[str], int]: ...
|
||||
def getabsfile(object: object) -> str: ...
|
||||
_SourceObjectType = Union[ModuleType, Type, MethodType, FunctionType,
|
||||
TracebackType, FrameType, CodeType]
|
||||
|
||||
def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ...
|
||||
def getabsfile(object: _SourceObjectType) -> str: ...
|
||||
def getblock(lines: Sequence[str]) -> Sequence[str]: ...
|
||||
def getdoc(object: object) -> Optional[str]: ...
|
||||
def getcomments(object: object) -> Optional[str]: ...
|
||||
def getfile(object: object) -> str: ...
|
||||
def getfile(object: _SourceObjectType) -> str: ...
|
||||
def getmodule(object: object) -> Optional[ModuleType]: ...
|
||||
def getsourcefile(object: object) -> Optional[str]: ...
|
||||
# TODO restrict to "module, class, method, function, traceback, frame,
|
||||
# or code object"
|
||||
def getsourcelines(object: object) -> Tuple[List[str], int]: ...
|
||||
# TODO restrict to "a module, class, method, function, traceback, frame,
|
||||
# or code object"
|
||||
def getsource(object: object) -> str: ...
|
||||
def getsourcefile(object: _SourceObjectType) -> Optional[str]: ...
|
||||
def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ...
|
||||
def getsource(object: _SourceObjectType) -> str: ...
|
||||
def cleandoc(doc: str) -> str: ...
|
||||
def indentsize(line: str) -> int: ...
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import sys
|
||||
from typing import (AbstractSet, Any, Callable, Dict, Generator, List, Mapping,
|
||||
NamedTuple, Optional, Sequence, Tuple, Union,
|
||||
NamedTuple, Optional, Sequence, Tuple, Type, Union,
|
||||
)
|
||||
from types import CodeType, FrameType, ModuleType, TracebackType
|
||||
from types import (CodeType, FrameType, FunctionType, MethodType, ModuleType,
|
||||
TracebackType,
|
||||
)
|
||||
from collections import OrderedDict
|
||||
|
||||
#
|
||||
@@ -75,20 +77,19 @@ def ismemberdescriptor(object: object) -> bool: ...
|
||||
#
|
||||
# Retrieving source code
|
||||
#
|
||||
def findsource(object: object) -> Tuple[List[str], int]: ...
|
||||
def getabsfile(object: object) -> str: ...
|
||||
_SourceObjectType = Union[ModuleType, Type, MethodType, FunctionType,
|
||||
TracebackType, FrameType, CodeType]
|
||||
|
||||
def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ...
|
||||
def getabsfile(object: _SourceObjectType) -> str: ...
|
||||
def getblock(lines: Sequence[str]) -> Sequence[str]: ...
|
||||
def getdoc(object: object) -> Optional[str]: ...
|
||||
def getcomments(object: object) -> Optional[str]: ...
|
||||
def getfile(object: object) -> str: ...
|
||||
def getfile(object: _SourceObjectType) -> str: ...
|
||||
def getmodule(object: object) -> Optional[ModuleType]: ...
|
||||
def getsourcefile(object: object) -> Optional[str]: ...
|
||||
# TODO restrict to "module, class, method, function, traceback, frame,
|
||||
# or code object"
|
||||
def getsourcelines(object: object) -> Tuple[List[str], int]: ...
|
||||
# TODO restrict to "a module, class, method, function, traceback, frame,
|
||||
# or code object"
|
||||
def getsource(object: object) -> str: ...
|
||||
def getsourcefile(object: _SourceObjectType) -> Optional[str]: ...
|
||||
def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ...
|
||||
def getsource(object: _SourceObjectType) -> str: ...
|
||||
def cleandoc(doc: str) -> str: ...
|
||||
def indentsize(line: str) -> int: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user