mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-17 08:35:03 +08:00
improve typing in inspect (#6020)
This commit is contained in:
@@ -117,10 +117,14 @@ if sys.version_info >= (3, 10):
|
||||
else:
|
||||
def signature(obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Signature: ...
|
||||
|
||||
class _void: ...
|
||||
class _empty: ...
|
||||
|
||||
class Signature:
|
||||
def __init__(self, parameters: Sequence[Parameter] | None = ..., *, return_annotation: Any = ...) -> None: ...
|
||||
# TODO: can we be more specific here?
|
||||
empty: object
|
||||
def __init__(
|
||||
self, parameters: Sequence[Parameter] | None = ..., *, return_annotation: Any = ..., __validate_parameters__: bool = ...
|
||||
) -> None: ...
|
||||
empty: _empty
|
||||
@property
|
||||
def parameters(self) -> types.MappingProxyType[str, Parameter]: ...
|
||||
# TODO: can we be more specific here?
|
||||
@@ -128,7 +132,9 @@ class Signature:
|
||||
def return_annotation(self) -> Any: ...
|
||||
def bind(self, *args: Any, **kwargs: Any) -> BoundArguments: ...
|
||||
def bind_partial(self, *args: Any, **kwargs: Any) -> BoundArguments: ...
|
||||
def replace(self: Self, *, parameters: Sequence[Parameter] | None = ..., return_annotation: Any = ...) -> Self: ...
|
||||
def replace(
|
||||
self: Self, *, parameters: Sequence[Parameter] | Type[_void] | None = ..., return_annotation: Any = ...
|
||||
) -> Self: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
@classmethod
|
||||
def from_callable(
|
||||
@@ -166,7 +172,7 @@ class _ParameterKind(enum.IntEnum):
|
||||
|
||||
class Parameter:
|
||||
def __init__(self, name: str, kind: _ParameterKind, *, default: Any = ..., annotation: Any = ...) -> None: ...
|
||||
empty: Any
|
||||
empty: _empty
|
||||
name: str
|
||||
default: Any
|
||||
annotation: Any
|
||||
@@ -178,7 +184,12 @@ class Parameter:
|
||||
KEYWORD_ONLY: ClassVar[Literal[_ParameterKind.KEYWORD_ONLY]]
|
||||
VAR_KEYWORD: ClassVar[Literal[_ParameterKind.VAR_KEYWORD]]
|
||||
def replace(
|
||||
self: Self, *, name: str | None = ..., kind: _ParameterKind | None = ..., default: Any = ..., annotation: Any = ...
|
||||
self: Self,
|
||||
*,
|
||||
name: str | Type[_void] = ...,
|
||||
kind: _ParameterKind | Type[_void] = ...,
|
||||
default: Any = ...,
|
||||
annotation: Any = ...,
|
||||
) -> Self: ...
|
||||
|
||||
class BoundArguments:
|
||||
|
||||
Reference in New Issue
Block a user