From cc9026896fc6ed9c54e3e62dc58f0603a42fe8a4 Mon Sep 17 00:00:00 2001 From: Carli* Freudenberg Date: Sat, 13 Jul 2024 15:09:23 +0200 Subject: [PATCH 01/12] Add copy_kwargs --- Doc/library/typing.rst | 30 ++++++++++++++++++++++++++++++ Lib/typing.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index a0beed4a8c77fb..d7450af3a2630e 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -281,6 +281,7 @@ callables, the :data:`Concatenate` operator may be used. They take the form ``Callable[ParamSpecVariable, ReturnType]`` and ``Callable[Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable], ReturnType]`` respectively. +To copy the call from one function to another use :func:`copy_kwargs`. .. versionchanged:: 3.10 ``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. @@ -2864,6 +2865,35 @@ Functions and decorators runtime we intentionally don't check anything (we want this to be as fast as possible). +.. decorator:: copy_kwargs(source_func) + + Cast the decorated function's call signature to the *source_func*'s. + + Use this decorator enhancing an upstream function while keeping it's + call signature. + Returns the original function with the *source_funcs* call signature. + + Usage:: + + from typing import copy_kwargs, Any + + def upstream_func(a: int, b: float, *, double: bool = False) -> float: + ... + + @copy_kwargs(upstream_func) + def enhanced( + a: int, b: float, *args: Any, double: bool = False, **kwargs: Any + ) -> str: + ... + + .. note:: + + Include ``*args`` and ``**kwargs`` in the signature of the decorated + function in order to avoid a :py:class:`TypeError` when the call signature of + *source_func* changes. + + .. versionadded 3.14 + .. function:: assert_type(val, typ, /) Ask a static type checker to confirm that *val* has an inferred type of *typ*. diff --git a/Lib/typing.py b/Lib/typing.py index f70dcd0b5b7b5c..3ea8f372e43ee3 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3752,6 +3752,44 @@ def get_protocol_members(tp: type, /) -> frozenset[str]: return frozenset(tp.__protocol_attrs__) +_P = ParamSpec("_P") + + +def copy_kwargs( + source_func: Callable[_P, Any] +) -> Callable[[Callable[..., T]], Callable[_P, T]]: + """Cast the decorated function's call signature to the source_func's. + + Use this decorator enhancing an upstream function while keeping it's + call signature. + Returns the original function with the *source_funcs* call signature. + + Usage:: + + from typing import copy_kwargs, Any + + def upstream_func(a: int, b: float, *, double: bool = False) -> float: + ... + + @copy_kwargs(upstream_func) + def enhanced( + a: int, b: float, *args: Any, double: bool = False, **kwargs: Any + ) -> str: + ... + + .. note:: + + Include ``*args`` and ``**kwargs`` in the signature of the decorated + function in order to avoid TypeErrors when the call signature of + *source_func* changes. + """ + + def return_func(func: Callable[..., T]) -> Callable[_P, T]: + return cast(Callable[_P, T], func) + + return return_func + + def __getattr__(attr): """Improve the import time of the typing module. From 08096128ce9e7ac2624f3713157df264e60fa682 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 13:20:44 +0000 Subject: [PATCH 02/12] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst diff --git a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst new file mode 100644 index 00000000000000..cce16a2e9c791e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst @@ -0,0 +1 @@ +Add :func:`copy_kwargs` to *typing* that copies/applies the ParameterSpec from one function to another. From 9ae1600c34b3bb7dce29922f8a453043cfa0058f Mon Sep 17 00:00:00 2001 From: Kound Date: Sat, 13 Jul 2024 15:40:32 +0200 Subject: [PATCH 03/12] Apply suggestions from code review Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/library/typing.rst | 2 +- Lib/typing.py | 2 +- .../next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index d7450af3a2630e..56bcc5033b346a 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2869,7 +2869,7 @@ Functions and decorators Cast the decorated function's call signature to the *source_func*'s. - Use this decorator enhancing an upstream function while keeping it's + Use this decorator enhancing an upstream function while keeping its call signature. Returns the original function with the *source_funcs* call signature. diff --git a/Lib/typing.py b/Lib/typing.py index 3ea8f372e43ee3..5efbe48fac1c5e 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3760,7 +3760,7 @@ def copy_kwargs( ) -> Callable[[Callable[..., T]], Callable[_P, T]]: """Cast the decorated function's call signature to the source_func's. - Use this decorator enhancing an upstream function while keeping it's + Use this decorator enhancing an upstream function while keeping its call signature. Returns the original function with the *source_funcs* call signature. diff --git a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst index cce16a2e9c791e..b7ae97deb82826 100644 --- a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst +++ b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst @@ -1 +1 @@ -Add :func:`copy_kwargs` to *typing* that copies/applies the ParameterSpec from one function to another. +Add :func:`~typing.copy_kwargs` to *typing* that copies/applies the ParameterSpec from one function to another. From 0e617393bc472f6563c92c642982cbf3960ec7ad Mon Sep 17 00:00:00 2001 From: Carli* Freudenberg Date: Sat, 13 Jul 2024 15:35:53 +0200 Subject: [PATCH 04/12] add copy_kwargs to __all__ --- Lib/typing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/typing.py b/Lib/typing.py index 5efbe48fac1c5e..34ce3d05b01931 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -125,6 +125,7 @@ 'assert_never', 'cast', 'clear_overloads', + 'copy_kwargs', 'dataclass_transform', 'evaluate_forward_ref', 'final', From 99c3e223db69d06c5101d9e0320c9ced215a0c8c Mon Sep 17 00:00:00 2001 From: Carli* Freudenberg Date: Sat, 13 Jul 2024 15:50:27 +0200 Subject: [PATCH 05/12] fix documentation issues - fix indent - add to whatsnew - add patch by to News file --- Doc/library/typing.rst | 36 +++++++++---------- Doc/whatsnew/3.14.rst | 3 ++ ...-07-13-13-20-43.gh-issue-107001.fRSPOX.rst | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 56bcc5033b346a..b824434e97b7a5 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2867,32 +2867,32 @@ Functions and decorators .. decorator:: copy_kwargs(source_func) - Cast the decorated function's call signature to the *source_func*'s. + Cast the decorated function's call signature to the *source_func*'s. - Use this decorator enhancing an upstream function while keeping its - call signature. - Returns the original function with the *source_funcs* call signature. + Use this decorator enhancing an upstream function while keeping its + call signature. + Returns the original function with the *source_funcs* call signature. - Usage:: + Usage:: - from typing import copy_kwargs, Any + from typing import copy_kwargs, Any - def upstream_func(a: int, b: float, *, double: bool = False) -> float: - ... + def upstream_func(a: int, b: float, *, double: bool = False) -> float: + ... - @copy_kwargs(upstream_func) - def enhanced( - a: int, b: float, *args: Any, double: bool = False, **kwargs: Any - ) -> str: - ... + @copy_kwargs(upstream_func) + def enhanced( + a: int, b: float, *args: Any, double: bool = False, **kwargs: Any + ) -> str: + ... - .. note:: + .. note:: - Include ``*args`` and ``**kwargs`` in the signature of the decorated - function in order to avoid a :py:class:`TypeError` when the call signature of - *source_func* changes. + Include ``*args`` and ``**kwargs`` in the signature of the decorated + function in order to avoid a :py:class:`TypeError` when the call signature of + *source_func* changes. - .. versionadded 3.14 + .. versionadded:: 3.14 .. function:: assert_type(val, typ, /) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index aaa4702d53df93..6ba344856f0cd9 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -1084,6 +1084,9 @@ symtable (Contributed by Bénédikt Tran in :gh:`120029`.) +typing +------ +* Add :func:`~typing.copy_kwargs` to *typing* that copies/applies the ParameterSpec from one function to another. sys --- diff --git a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst index b7ae97deb82826..52c706577773ae 100644 --- a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst +++ b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst @@ -1 +1 @@ -Add :func:`~typing.copy_kwargs` to *typing* that copies/applies the ParameterSpec from one function to another. +Add :func:`~typing.copy_kwargs` to *typing* that copies/applies the ParameterSpec from one function to another. Patch by Carli Freudenberg. From 10888c2507d30a56dc3d9d38eb9bcec64de5f798 Mon Sep 17 00:00:00 2001 From: Kound Date: Sat, 13 Jul 2024 16:18:47 +0200 Subject: [PATCH 06/12] Apply suggestions from code review Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/library/typing.rst | 2 +- Lib/typing.py | 2 +- .../Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index b824434e97b7a5..9bb75117e67116 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2871,7 +2871,7 @@ Functions and decorators Use this decorator enhancing an upstream function while keeping its call signature. - Returns the original function with the *source_funcs* call signature. + Returns the original function with the *source_func*'s call signature. Usage:: diff --git a/Lib/typing.py b/Lib/typing.py index 34ce3d05b01931..53cbb0621d3955 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3763,7 +3763,7 @@ def copy_kwargs( Use this decorator enhancing an upstream function while keeping its call signature. - Returns the original function with the *source_funcs* call signature. + Returns the original function with the source_func's call signature. Usage:: diff --git a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst index 52c706577773ae..cafd81996aa70f 100644 --- a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst +++ b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst @@ -1 +1,2 @@ -Add :func:`~typing.copy_kwargs` to *typing* that copies/applies the ParameterSpec from one function to another. Patch by Carli Freudenberg. +Add :func:`~typing.copy_kwargs` to :mod:`typing` that copies/applies the +ParameterSpec from one function to another. Patch by Carli Freudenberg. From 182e187b9d96954db06c73ccdddc5c50a7b4484b Mon Sep 17 00:00:00 2001 From: Carli* Freudenberg Date: Sat, 13 Jul 2024 16:22:59 +0200 Subject: [PATCH 07/12] fix too long lines --- Doc/whatsnew/3.14.rst | 3 ++- .../Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 6ba344856f0cd9..df68a4370e6560 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -1086,7 +1086,8 @@ symtable typing ------ -* Add :func:`~typing.copy_kwargs` to *typing* that copies/applies the ParameterSpec from one function to another. +* Add :func:`~typing.copy_kwargs` to *typing* that copies/applies + the :class:`~typing.ParamSpec` from one function to another. sys --- diff --git a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst index cafd81996aa70f..4befb9051eea69 100644 --- a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst +++ b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst @@ -1,2 +1,3 @@ Add :func:`~typing.copy_kwargs` to :mod:`typing` that copies/applies the -ParameterSpec from one function to another. Patch by Carli Freudenberg. +:class:`~typing.ParamSpec` from one function to another. +Patch by Carli Freudenberg. From d2f1fc49abfdefa8b517210d5b869a3bf0afceab Mon Sep 17 00:00:00 2001 From: Carli* Freudenberg Date: Sat, 13 Jul 2024 16:24:54 +0200 Subject: [PATCH 08/12] docs: remove not needed "typing" word --- Doc/whatsnew/3.14.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index df68a4370e6560..a01498364bed59 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -1086,7 +1086,7 @@ symtable typing ------ -* Add :func:`~typing.copy_kwargs` to *typing* that copies/applies +* Add :func:`~typing.copy_kwargs` that copies/applies the :class:`~typing.ParamSpec` from one function to another. sys From 268be85e1eb5afd94721cac372178815c317436f Mon Sep 17 00:00:00 2001 From: Carli* Freudenberg Date: Fri, 25 Oct 2024 16:02:49 +0200 Subject: [PATCH 09/12] rename: copy_kwargs to copy_func_params --- Doc/library/typing.rst | 8 ++++---- Doc/whatsnew/3.14.rst | 2 +- Lib/typing.py | 8 ++++---- .../2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 9bb75117e67116..7465c073a025ba 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -281,7 +281,7 @@ callables, the :data:`Concatenate` operator may be used. They take the form ``Callable[ParamSpecVariable, ReturnType]`` and ``Callable[Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable], ReturnType]`` respectively. -To copy the call from one function to another use :func:`copy_kwargs`. +To copy the call from one function to another use :func:`copy_func_params`. .. versionchanged:: 3.10 ``Callable`` now supports :class:`ParamSpec` and :data:`Concatenate`. @@ -2865,7 +2865,7 @@ Functions and decorators runtime we intentionally don't check anything (we want this to be as fast as possible). -.. decorator:: copy_kwargs(source_func) +.. decorator:: copy_func_params(source_func) Cast the decorated function's call signature to the *source_func*'s. @@ -2875,12 +2875,12 @@ Functions and decorators Usage:: - from typing import copy_kwargs, Any + from typing import copy_func_params, Any def upstream_func(a: int, b: float, *, double: bool = False) -> float: ... - @copy_kwargs(upstream_func) + @copy_func_params(upstream_func) def enhanced( a: int, b: float, *args: Any, double: bool = False, **kwargs: Any ) -> str: diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index a01498364bed59..2d104e035cc7d7 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -1086,7 +1086,7 @@ symtable typing ------ -* Add :func:`~typing.copy_kwargs` that copies/applies +* Add :func:`~typing.copy_func_params` that copies/applies the :class:`~typing.ParamSpec` from one function to another. sys diff --git a/Lib/typing.py b/Lib/typing.py index 53cbb0621d3955..0729b336cc4340 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -125,7 +125,7 @@ 'assert_never', 'cast', 'clear_overloads', - 'copy_kwargs', + 'copy_func_params', 'dataclass_transform', 'evaluate_forward_ref', 'final', @@ -3756,7 +3756,7 @@ def get_protocol_members(tp: type, /) -> frozenset[str]: _P = ParamSpec("_P") -def copy_kwargs( +def copy_func_params( source_func: Callable[_P, Any] ) -> Callable[[Callable[..., T]], Callable[_P, T]]: """Cast the decorated function's call signature to the source_func's. @@ -3767,12 +3767,12 @@ def copy_kwargs( Usage:: - from typing import copy_kwargs, Any + from typing import copy_func_params, Any def upstream_func(a: int, b: float, *, double: bool = False) -> float: ... - @copy_kwargs(upstream_func) + @copy_func_params(upstream_func) def enhanced( a: int, b: float, *args: Any, double: bool = False, **kwargs: Any ) -> str: diff --git a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst index 4befb9051eea69..3519e8a20f51d7 100644 --- a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst +++ b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst @@ -1,3 +1,3 @@ -Add :func:`~typing.copy_kwargs` to :mod:`typing` that copies/applies the +Add :func:`~typing.copy_func_params` to :mod:`typing` that copies/applies the :class:`~typing.ParamSpec` from one function to another. Patch by Carli Freudenberg. From 0900d669a0d214552b48bec793c60eebc571c7ec Mon Sep 17 00:00:00 2001 From: Carli* Freudenberg Date: Fri, 25 Oct 2024 16:30:22 +0200 Subject: [PATCH 10/12] Use PEP 695 syntax --- Lib/typing.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Lib/typing.py b/Lib/typing.py index 0729b336cc4340..10ef8a0a8be1a2 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3753,12 +3753,9 @@ def get_protocol_members(tp: type, /) -> frozenset[str]: return frozenset(tp.__protocol_attrs__) -_P = ParamSpec("_P") - - -def copy_func_params( - source_func: Callable[_P, Any] -) -> Callable[[Callable[..., T]], Callable[_P, T]]: +def copy_func_params[**Param, RV]( + source_func: Callable[Param, Any] +) -> Callable[[Callable[..., RV]], Callable[Param, RV]]: """Cast the decorated function's call signature to the source_func's. Use this decorator enhancing an upstream function while keeping its @@ -3785,8 +3782,8 @@ def enhanced( *source_func* changes. """ - def return_func(func: Callable[..., T]) -> Callable[_P, T]: - return cast(Callable[_P, T], func) + def return_func(func: Callable[..., RV]) -> Callable[Param, RV]: + return cast(Callable[Param, RV], func) return return_func From df1fc2686c8441bb6baead834a7cb3e651b5c66b Mon Sep 17 00:00:00 2001 From: Carli* Freudenberg Date: Fri, 25 Oct 2024 18:16:44 +0200 Subject: [PATCH 11/12] add copy_method_params as well --- Doc/library/typing.rst | 10 ++++++++++ Lib/typing.py | 20 +++++++++++++++++++ ...-07-13-13-20-43.gh-issue-107001.fRSPOX.rst | 5 +++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 7465c073a025ba..dbcbcff4992364 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2894,6 +2894,16 @@ Functions and decorators .. versionadded:: 3.14 + +.. decorator:: copy_method_params(source_method) + + Cast the decorated method's call signature to the source_method's + + Same as :py:func:`copy_func_params` but intended to be used with methods. + It keeps the first argument (``self``/``cls``) of the decorated method. + + .. versionadded:: 3.14 + .. function:: assert_type(val, typ, /) Ask a static type checker to confirm that *val* has an inferred type of *typ*. diff --git a/Lib/typing.py b/Lib/typing.py index 10ef8a0a8be1a2..f8747682b72e37 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3788,6 +3788,26 @@ def return_func(func: Callable[..., RV]) -> Callable[Param, RV]: return return_func +def copy_method_params[**Param, Arg1, RV]( + source_method: Callable[Concatenate[Any, Param], Any] +) -> Callable[ + [Callable[Concatenate[Arg1, ...], RV]], + Callable[Concatenate[Arg1, Param], RV] +]: + """Cast the decorated method's call signature to the source_method's. + + Same as :func:`copy_func_params` but intended to be used with methods. + It keeps the first argument (``self``/``cls``) of the decorated method. + """ + + def return_func( + func: Callable[Concatenate[Arg1, ...], RV] + ) -> Callable[Concatenate[Arg1, Param], RV]: + return cast(Callable[Concatenate[Arg1, Param], RV], func) + + return return_func + + def __getattr__(attr): """Improve the import time of the typing module. diff --git a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst index 3519e8a20f51d7..6b11ae26546598 100644 --- a/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst +++ b/Misc/NEWS.d/next/Library/2024-07-13-13-20-43.gh-issue-107001.fRSPOX.rst @@ -1,3 +1,4 @@ -Add :func:`~typing.copy_func_params` to :mod:`typing` that copies/applies the -:class:`~typing.ParamSpec` from one function to another. +Add :func:`~typing.copy_func_params` and :func:`~typing.copy_func_params` +to :mod:`typing` that copies/applies the +:class:`~typing.ParamSpec` from one function/method to another. Patch by Carli Freudenberg. From 3fbe3b75cc7aa62ef13a08bb37eae9bec4b5f43b Mon Sep 17 00:00:00 2001 From: Carli* Freudenberg Date: Mon, 28 Oct 2024 01:09:07 +0100 Subject: [PATCH 12/12] add copy_method_params to all as well --- Lib/typing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/typing.py b/Lib/typing.py index f8747682b72e37..03ffeed9d1e0d9 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -126,6 +126,7 @@ 'cast', 'clear_overloads', 'copy_func_params', + 'copy_method_params', 'dataclass_transform', 'evaluate_forward_ref', 'final',