Skip to content

Commit 45eab5a

Browse files
committed
dont destroy type of decorated function
1 parent a5ec7fd commit 45eab5a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

line_profiler/explicit_profiler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def func4():
171171
import pathlib
172172
import sys
173173
import typing
174-
from typing import Any, Callable, TypeVar
174+
from typing import Any, Callable, ParamSpec, TypeVar
175175

176176
if typing.TYPE_CHECKING:
177177
ConfigArg = str | pathlib.PurePath | bool | None
@@ -183,6 +183,8 @@ def func4():
183183
from .toml_config import ConfigSource
184184

185185
F = TypeVar('F', bound=Callable[..., Any])
186+
P = ParamSpec('P')
187+
R = TypeVar('R')
186188

187189
# The first process that enables profiling records its PID here. Child processes
188190
# created via multiprocessing (spawn/forkserver) inherit this environment value,
@@ -427,7 +429,7 @@ def disable(self) -> None:
427429
"""
428430
self.enabled = False
429431

430-
def __call__(self, func: Callable) -> Callable:
432+
def __call__(self, func: Callable[P, R]) -> Callable[P, R]:
431433
"""
432434
If the global profiler is enabled, decorate a function to start the
433435
profiler on function entry and stop it on function exit. Otherwise

0 commit comments

Comments
 (0)