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.
- sg_python_api-0.1.0.dist-info/METADATA +177 -0
- sg_python_api-0.1.0.dist-info/RECORD +31 -0
- sg_python_api-0.1.0.dist-info/WHEEL +4 -0
- sg_python_api-0.1.0.dist-info/licenses/LICENSE +21 -0
- shotgun_api3/__init__.py +68 -0
- shotgun_api3/_async_client.py +2906 -0
- shotgun_api3/_async_driver.py +945 -0
- shotgun_api3/_async_httpx2.py +662 -0
- shotgun_api3/_async_transport.py +162 -0
- shotgun_api3/_capabilities.py +165 -0
- shotgun_api3/_client.py +2682 -0
- shotgun_api3/_config.py +1463 -0
- shotgun_api3/_crud.py +916 -0
- shotgun_api3/_driver.py +879 -0
- shotgun_api3/_errors.py +49 -0
- shotgun_api3/_execution.py +273 -0
- shotgun_api3/_files.py +1094 -0
- shotgun_api3/_methods.py +1205 -0
- shotgun_api3/_protocol.py +1347 -0
- shotgun_api3/_sentinel.py +5 -0
- shotgun_api3/_sg_timezone.py +5 -0
- shotgun_api3/_signatures.py +53 -0
- shotgun_api3/_transport.py +901 -0
- shotgun_api3/_version.py +3 -0
- shotgun_api3/lib/__init__.py +1 -0
- shotgun_api3/lib/mockgun/__init__.py +16 -0
- shotgun_api3/lib/mockgun/_async.py +315 -0
- shotgun_api3/lib/mockgun/_mockgun.py +1666 -0
- shotgun_api3/lib/sgtimezone.py +209 -0
- shotgun_api3/py.typed +0 -0
- shotgun_api3/shotgun.py +58 -0
|
@@ -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
|