bookalimo 0.1.4__tar.gz → 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bookalimo
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Python wrapper for the Book-A-Limo API
5
5
  Author-email: Jonathan Oren <jonathan@bookalimo.com>
6
6
  Maintainer-email: Jonathan Oren <jonathan@bookalimo.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "bookalimo"
7
- version = "0.1.4"
7
+ version = "0.1.5"
8
8
  description = "Python wrapper for the Book-A-Limo API"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -8,9 +8,15 @@ from __future__ import annotations
8
8
  import logging
9
9
  import os
10
10
  import re
11
- from collections.abc import Iterable, Mapping
11
+ from collections.abc import Awaitable, Iterable, Mapping
12
+ from functools import wraps
12
13
  from time import perf_counter
13
- from typing import Any, Callable
14
+ from typing import Any, Callable, TypeVar
15
+
16
+ from typing_extensions import ParamSpec
17
+
18
+ P = ParamSpec("P")
19
+ R = TypeVar("R")
14
20
 
15
21
  logger = logging.getLogger("bookalimo")
16
22
  logger.addHandler(logging.NullHandler())
@@ -178,27 +184,19 @@ def log_call(
178
184
  include_params: Iterable[str] | None = None,
179
185
  transforms: Mapping[str, Callable[[Any], Any]] | None = None,
180
186
  operation: str | None = None,
181
- ) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
182
- """
183
- Decorator for async SDK methods.
184
- - DEBUG: logs start/end with sanitized params + duration
185
- - WARNING: logs errors (sanitized). No overhead when DEBUG is off.
186
- """
187
+ ) -> Callable[[Callable[P, Awaitable[R]]], Callable[P, Awaitable[R]]]:
187
188
  include = set(include_params or [])
188
189
  transforms = transforms or {}
189
190
 
190
- def _decorate(fn: Callable[..., Any]) -> Callable[..., Any]:
191
- async def _async_wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
191
+ def _decorate(fn: Callable[P, Awaitable[R]]) -> Callable[P, Awaitable[R]]:
192
+ @wraps(fn)
193
+ async def _async_wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
192
194
  log = get_logger("wrapper")
193
195
  op = operation or fn.__name__
194
196
 
195
- # Fast path: if debug disabled, skip param binding/redaction entirely
196
197
  debug_on = log.isEnabledFor(logging.DEBUG)
197
198
  if debug_on:
198
- # Build a minimal, sanitized args snapshot
199
199
  snapshot: dict[str, Any] = {}
200
- # Map positional args to param names without inspect overhead by relying on kwargs only:
201
- # we assume call sites are using kwargs in the wrapper (they do).
202
200
  for k in include:
203
201
  val = kwargs.get(k, None)
204
202
  if k in transforms:
@@ -209,7 +207,6 @@ def log_call(
209
207
  else:
210
208
  val = redact_param(k, val)
211
209
  snapshot[k] = val
212
-
213
210
  start = perf_counter()
214
211
  log.debug(
215
212
  "→ %s(%s)",
@@ -219,21 +216,18 @@ def log_call(
219
216
  )
220
217
 
221
218
  try:
222
- result = await fn(self, *args, **kwargs)
219
+ result = await fn(*args, **kwargs)
223
220
  if debug_on:
224
221
  dur_ms = (perf_counter() - start) * 1000.0
225
- # Keep result logging ultra-light
226
- result_type = type(result).__name__
227
222
  log.debug(
228
223
  "← %s ok in %.1f ms (%s)",
229
224
  op,
230
225
  dur_ms,
231
- result_type,
226
+ type(result).__name__,
232
227
  extra={"operation": op},
233
228
  )
234
229
  return result
235
230
  except Exception as e:
236
- # WARNING with sanitized error; no param dump on failures
237
231
  log.warning(
238
232
  "%s failed: %s", op, e.__class__.__name__, extra={"operation": op}
239
233
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bookalimo
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Python wrapper for the Book-A-Limo API
5
5
  Author-email: Jonathan Oren <jonathan@bookalimo.com>
6
6
  Maintainer-email: Jonathan Oren <jonathan@bookalimo.com>
File without changes
File without changes
File without changes