Make SigParameter.replace and Signature.replace return Self (#5689)

This commit is contained in:
Jelle Zijlstra
2021-06-24 09:01:58 -07:00
committed by GitHub
parent 2cd7e6511b
commit 5fe2459779

View File

@@ -1,5 +1,6 @@
import enum
import sys
from _typeshed import Self
from collections import OrderedDict
from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence, Set
from types import (
@@ -128,7 +129,7 @@ class Signature:
return_annotation: Any
def bind(self, *args: Any, **kwargs: Any) -> BoundArguments: ...
def bind_partial(self, *args: Any, **kwargs: Any) -> BoundArguments: ...
def replace(self, *, parameters: Optional[Sequence[Parameter]] = ..., return_annotation: Any = ...) -> Signature: ...
def replace(self: Self, *, parameters: Optional[Sequence[Parameter]] = ..., return_annotation: Any = ...) -> Self: ...
if sys.version_info >= (3, 10):
@classmethod
def from_callable(
@@ -178,8 +179,8 @@ class Parameter:
KEYWORD_ONLY: ClassVar[Literal[_ParameterKind.KEYWORD_ONLY]]
VAR_KEYWORD: ClassVar[Literal[_ParameterKind.VAR_KEYWORD]]
def replace(
self, *, name: Optional[str] = ..., kind: Optional[_ParameterKind] = ..., default: Any = ..., annotation: Any = ...
) -> Parameter: ...
self: Self, *, name: Optional[str] = ..., kind: Optional[_ParameterKind] = ..., default: Any = ..., annotation: Any = ...
) -> Self: ...
class BoundArguments:
arguments: OrderedDict[str, Any]