From 5884ee29777437f95e135c474226615fd65aadce Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Mon, 31 Aug 2020 14:23:01 -0700 Subject: [PATCH] inspect: minor improvements (#4499) Co-authored-by: hauntsaninja <> --- stdlib/3/inspect.pyi | 21 ++++++++++++++++----- tests/stubtest_whitelists/py38.txt | 3 --- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/stdlib/3/inspect.pyi b/stdlib/3/inspect.pyi index fbc7508a5..861902948 100644 --- a/stdlib/3/inspect.pyi +++ b/stdlib/3/inspect.pyi @@ -62,14 +62,24 @@ def ismodule(object: object) -> bool: ... def isclass(object: object) -> bool: ... def ismethod(object: object) -> bool: ... def isfunction(object: object) -> bool: ... -def isgeneratorfunction(object: object) -> bool: ... + +if sys.version_info >= (3, 8): + def isgeneratorfunction(obj: object) -> bool: ... + def iscoroutinefunction(obj: object) -> bool: ... + +else: + def isgeneratorfunction(object: object) -> bool: ... + def iscoroutinefunction(object: object) -> bool: ... + def isgenerator(object: object) -> bool: ... -def iscoroutinefunction(object: object) -> bool: ... def iscoroutine(object: object) -> bool: ... def isawaitable(object: object) -> bool: ... if sys.version_info >= (3, 6): - def isasyncgenfunction(object: object) -> bool: ... + if sys.version_info >= (3, 8): + def isasyncgenfunction(obj: object) -> bool: ... + else: + def isasyncgenfunction(object: object) -> bool: ... def isasyncgen(object: object) -> bool: ... def istraceback(object: object) -> bool: ... @@ -89,12 +99,12 @@ def ismemberdescriptor(object: object) -> bool: ... _SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]] def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ... -def getabsfile(object: _SourceObjectType) -> str: ... +def getabsfile(object: _SourceObjectType, _filename: Optional[str] = ...) -> str: ... def getblock(lines: Sequence[str]) -> Sequence[str]: ... def getdoc(object: object) -> Optional[str]: ... def getcomments(object: object) -> Optional[str]: ... def getfile(object: _SourceObjectType) -> str: ... -def getmodule(object: object) -> Optional[ModuleType]: ... +def getmodule(object: object, _filename: Optional[str] = ...) -> Optional[ModuleType]: ... def getsourcefile(object: _SourceObjectType) -> Optional[str]: ... def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ... def getsource(object: _SourceObjectType) -> str: ... @@ -154,6 +164,7 @@ class BoundArguments: args: Tuple[Any, ...] kwargs: Dict[str, Any] signature: Signature + def __init__(self, signature: Signature, arguments: OrderedDict[str, Any]) -> None: ... def apply_defaults(self) -> None: ... # diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_whitelists/py38.txt index 081529b3c..4da2d3eb3 100644 --- a/tests/stubtest_whitelists/py38.txt +++ b/tests/stubtest_whitelists/py38.txt @@ -50,9 +50,6 @@ http.cookiejar.DefaultCookiePolicy.__init__ http.server.SimpleHTTPRequestHandler.__init__ importlib.metadata.DistributionFinder.Context.pattern importlib.metadata.EntryPointBase -inspect.isasyncgenfunction -inspect.iscoroutinefunction -inspect.isgeneratorfunction ipaddress.IPv4Interface.hostmask ipaddress.IPv6Interface.hostmask ipaddress._BaseNetwork.broadcast_address