Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve inspect callbacks #8189

Merged
merged 1 commit into from
Jun 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions stdlib/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,14 @@ def getsource(object: _SourceObjectType) -> str: ...
def cleandoc(doc: str) -> str: ...
def indentsize(line: str) -> int: ...

_IntrospectableCallable: TypeAlias = Callable[..., Any]

#
# Introspecting callables with the Signature object
#
if sys.version_info >= (3, 10):
def signature(
obj: Callable[..., Any],
obj: _IntrospectableCallable,
*,
follow_wrapped: bool = ...,
globals: Mapping[str, Any] | None = ...,
Expand All @@ -275,7 +277,7 @@ if sys.version_info >= (3, 10):
) -> Signature: ...

else:
def signature(obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Signature: ...
def signature(obj: _IntrospectableCallable, *, follow_wrapped: bool = ...) -> Signature: ...

class _void: ...
class _empty: ...
Expand All @@ -298,7 +300,7 @@ class Signature:
@classmethod
def from_callable(
cls: type[Self],
obj: Callable[..., Any],
obj: _IntrospectableCallable,
*,
follow_wrapped: bool = ...,
globals: Mapping[str, Any] | None = ...,
Expand All @@ -307,13 +309,13 @@ class Signature:
) -> Self: ...
else:
@classmethod
def from_callable(cls: type[Self], obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Self: ...
def from_callable(cls: type[Self], obj: _IntrospectableCallable, *, follow_wrapped: bool = ...) -> Self: ...

def __eq__(self, other: object) -> bool: ...

if sys.version_info >= (3, 10):
def get_annotations(
obj: Callable[..., Any] | type[Any] | ModuleType,
obj: Callable[..., object] | type[Any] | ModuleType,
*,
globals: Mapping[str, Any] | None = ...,
locals: Mapping[str, Any] | None = ...,
Expand Down Expand Up @@ -453,8 +455,8 @@ class ClosureVars(NamedTuple):
builtins: Mapping[str, Any]
unbound: AbstractSet[str]

def getclosurevars(func: Callable[..., Any]) -> ClosureVars: ...
def unwrap(func: Callable[..., Any], *, stop: Callable[[Any], Any] | None = ...) -> Any: ...
def getclosurevars(func: _IntrospectableCallable) -> ClosureVars: ...
def unwrap(func: Callable[..., Any], *, stop: Callable[[Callable[..., Any]], Any] | None = ...) -> Any: ...

#
# The interpreter stack
Expand Down