Skip to content

Commit ba1dadd

Browse files
authored
fix: decorator type erasure (#3321)
1 parent 17f20eb commit ba1dadd

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

sqlmesh/core/analytics/__init__.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
from sqlmesh.core.analytics.dispatcher import AsyncEventDispatcher, NoopEventDispatcher
1010
from sqlmesh.utils import str_to_bool
1111

12+
if t.TYPE_CHECKING:
13+
import sys
14+
15+
if sys.version_info >= (3, 10):
16+
from typing import ParamSpec
17+
else:
18+
from typing_extensions import ParamSpec
19+
20+
_P = ParamSpec("_P")
21+
_T = t.TypeVar("_T")
22+
1223

1324
def init_collector() -> AnalyticsCollector:
1425
dispatcher = (
@@ -31,9 +42,9 @@ def disable_analytics() -> None:
3142
collector = AnalyticsCollector(dispatcher=NoopEventDispatcher())
3243

3344

34-
def cli_analytics(func: t.Callable[..., t.Any]) -> t.Callable[..., t.Any]:
45+
def cli_analytics(func: t.Callable[_P, _T]) -> t.Callable[_P, _T]:
3546
@wraps(func)
36-
def wrapper(*args: t.List[t.Any], **kwargs: t.Any) -> t.Any:
47+
def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _T:
3748
import click
3849
from click.core import ParameterSource
3950

@@ -73,9 +84,9 @@ def wrapper(*args: t.List[t.Any], **kwargs: t.Any) -> t.Any:
7384
return wrapper
7485

7586

76-
def python_api_analytics(func: t.Callable[..., t.Any]) -> t.Callable[..., t.Any]:
87+
def python_api_analytics(func: t.Callable[_P, _T]) -> t.Callable[_P, _T]:
7788
@wraps(func)
78-
def wrapper(*args: t.List[t.Any], **kwargs: t.Any) -> t.Any:
89+
def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _T:
7990
import inspect
8091

8192
from sqlmesh import magics

0 commit comments

Comments
 (0)