sg-python-api 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,5 @@
1
+ """Internal sentinel types."""
2
+
3
+
4
+ class Unset:
5
+ """Represent an official setting that has not been configured."""
@@ -0,0 +1,5 @@
1
+ """Own the process-wide timezone singleton."""
2
+
3
+ from .lib.sgtimezone import SgTimezone
4
+
5
+ SG_TIMEZONE = SgTimezone()
@@ -0,0 +1,53 @@
1
+ """Shared argument binding and callable reflection metadata."""
2
+
3
+ import inspect
4
+ from collections.abc import Callable, Mapping
5
+
6
+
7
+ def bind_arguments(
8
+ signature: inspect.Signature,
9
+ args: tuple[object, ...],
10
+ kwargs: Mapping[str, object],
11
+ label: str,
12
+ ) -> inspect.BoundArguments:
13
+ """Bind arguments and defaults with a caller-specific error prefix.
14
+
15
+ Args:
16
+ signature: Public call signature to enforce.
17
+ args: Supplied positional arguments.
18
+ kwargs: Supplied keyword arguments.
19
+ label: Public callable label, including parentheses, for errors.
20
+
21
+ Returns:
22
+ Bound arguments retaining the supplied values without copying them.
23
+
24
+ Raises:
25
+ TypeError: If binding fails, prefixed with the callable label.
26
+ """
27
+ try:
28
+ bound = signature.bind(*args, **kwargs)
29
+ except TypeError as exc:
30
+ raise TypeError(f'{label} {exc}') from None
31
+ bound.apply_defaults()
32
+ return bound
33
+
34
+
35
+ def expose_signature(
36
+ function: Callable[..., object],
37
+ signature: inspect.Signature,
38
+ doc: str | None,
39
+ ) -> Callable[..., object]:
40
+ """Attach a signature and optional documentation to the same callable.
41
+
42
+ Args:
43
+ function: Implementation receiving public reflection metadata.
44
+ signature: Public signature to expose.
45
+ doc: Replacement documentation, or `None` to preserve the docstring.
46
+
47
+ Returns:
48
+ The same callable with its reflection metadata updated.
49
+ """
50
+ if doc is not None:
51
+ object.__setattr__(function, '__doc__', doc)
52
+ object.__setattr__(function, '__signature__', signature)
53
+ return function