Skip to content

Commit 77adc00

Browse files
committed
work in progress
1 parent 9ba19be commit 77adc00

1 file changed

Lines changed: 19 additions & 22 deletions

File tree

src/query_farm_server_base/server.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
SCHEMA_TOP_LEVEL_COMPRESSION_LEVEL = 12
2020

2121

22-
P = ParamSpec("P")
23-
R = TypeVar("R")
24-
25-
2622
log = structlog.get_logger()
2723

2824
AccountType = TypeVar("AccountType", bound=auth.Account)
@@ -67,25 +63,26 @@ class AirportSerializedCatalogRoot(BaseModel):
6763
version_info: GetCatalogVersionResult
6864

6965

66+
P = ParamSpec("P")
67+
R = TypeVar("R")
68+
69+
7070
# 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
8986

9087

9188
class BasicFlightServer(flight.FlightServerBase, Generic[AccountType, TokenType], ABC):

0 commit comments

Comments
 (0)