inspect: use more specific arg type for some source retrieve functions (#3155)

This commit is contained in:
Ville Skyttä
2019-07-30 18:53:56 +03:00
committed by Sebastian Rittau
parent bd2d0fcc85
commit c6cbe4da66
2 changed files with 23 additions and 23 deletions

View File

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

View File

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