|
19 | 19 | SCHEMA_TOP_LEVEL_COMPRESSION_LEVEL = 12 |
20 | 20 |
|
21 | 21 |
|
22 | | -P = ParamSpec("P") |
23 | | -R = TypeVar("R") |
24 | | - |
25 | | - |
26 | 22 | log = structlog.get_logger() |
27 | 23 |
|
28 | 24 | AccountType = TypeVar("AccountType", bound=auth.Account) |
@@ -67,25 +63,26 @@ class AirportSerializedCatalogRoot(BaseModel): |
67 | 63 | version_info: GetCatalogVersionResult |
68 | 64 |
|
69 | 65 |
|
| 66 | +P = ParamSpec("P") |
| 67 | +R = TypeVar("R") |
| 68 | + |
| 69 | + |
70 | 70 | # Setup a decorator to log the action and its parameters. |
71 | | -def log_action() -> Callable[[Callable[P, R]], Callable[P, R]]: |
72 | | - def decorator(func: Callable[P, R]) -> Callable[P, R]: |
73 | | - @functools.wraps(func) |
74 | | - def wrapper(*args: P.args, **kwargs: P.kwargs) -> R: |
75 | | - func_name = func.__name__ |
76 | | - |
77 | | - # Example: log a known kwarg |
78 | | - if "context" in kwargs: |
79 | | - context = cast(CallContext[Any, Any], kwargs["context"]) |
80 | | - context.logger.debug(func_name, parameters=kwargs["parameters"]) |
81 | | - print("Calling function:", func_name) |
82 | | - result = func(*args, **kwargs) |
83 | | - print("got result") |
84 | | - return result |
85 | | - |
86 | | - return wrapper |
87 | | - |
88 | | - return decorator |
| 71 | +def log_action(func: Callable[..., R]) -> Callable[P, R]: |
| 72 | + @functools.wraps(func) |
| 73 | + def wrapper(*args: P.args, **kwargs: P.kwargs) -> R: |
| 74 | + func_name = func.__name__ |
| 75 | + |
| 76 | + # Example: log a known kwarg |
| 77 | + if "context" in kwargs: |
| 78 | + context = cast(CallContext[Any, Any], kwargs["context"]) |
| 79 | + context.logger.debug(func_name, parameters=kwargs["parameters"]) |
| 80 | + print("Calling function:", func_name) |
| 81 | + result = func(*args, **kwargs) |
| 82 | + print("got result") |
| 83 | + return result |
| 84 | + |
| 85 | + return wrapper |
89 | 86 |
|
90 | 87 |
|
91 | 88 | class BasicFlightServer(flight.FlightServerBase, Generic[AccountType, TokenType], ABC): |
|
0 commit comments