Skip to content

Commit 8bb7a25

Browse files
Add TypeVar to deprecate_kwarg to preserve type information (#1348)
Co-authored-by: Herbert Rusznak <[email protected]>
1 parent f515d2c commit 8bb7a25

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cadquery/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
from functools import wraps
22
from inspect import signature
3+
from typing import TypeVar, Callable, cast
34
from warnings import warn
45

56
from multimethod import multimethod, DispatchError
67

8+
TCallable = TypeVar("TCallable", bound=Callable)
9+
710

811
class deprecate_kwarg:
912
def __init__(self, name, new_value):
1013

1114
self.name = name
1215
self.new_value = new_value
1316

14-
def __call__(self, f):
17+
def __call__(self, f: TCallable) -> TCallable:
1518
@wraps(f)
1619
def wrapped(*args, **kwargs):
1720

@@ -25,7 +28,7 @@ def wrapped(*args, **kwargs):
2528

2629
return f(*args, **kwargs)
2730

28-
return wrapped
31+
return cast(TCallable, wrapped)
2932

3033

3134
class deprecate:

0 commit comments

Comments
 (0)