mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +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:
|
||||
|
||||
@@ -96,13 +96,13 @@ importlib.abc.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined
|
||||
importlib.abc.MetaPathFinder.find_spec # Not defined on the actual class, but expected to exist.
|
||||
importlib.abc.PathEntryFinder.find_spec # Not defined on the actual class, but expected to exist.
|
||||
importlib.machinery.ExtensionFileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature
|
||||
inspect.Parameter.empty # set as private marker _empty
|
||||
inspect.Parameter.KEYWORD_ONLY
|
||||
inspect.Parameter.POSITIONAL_ONLY
|
||||
inspect.Parameter.POSITIONAL_OR_KEYWORD
|
||||
inspect.Parameter.VAR_KEYWORD
|
||||
inspect.Parameter.VAR_POSITIONAL
|
||||
inspect.Parameter.replace
|
||||
inspect.Signature.replace
|
||||
inspect.Signature.empty # set as private marker _empty
|
||||
io.BufferedRandom.truncate
|
||||
io.BufferedReader.seek
|
||||
io.BufferedReader.truncate
|
||||
|
||||
Reference in New Issue
Block a user