iris-pex-embedded-python 4.0.1b2__py3-none-any.whl → 4.0.1b3__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.
iop/messages/dispatch.py CHANGED
@@ -306,8 +306,9 @@ def get_handler_info(host: Any, method_name: str) -> tuple[str, str] | None:
306
306
  if len(params) != 1:
307
307
  return None
308
308
 
309
+ method = getattr(host, method_name)
309
310
  param: Parameter = next(iter(params.values()))
310
- annotation = param.annotation
311
+ annotation = _resolve_annotation(host, method, param.annotation)
311
312
 
312
313
  if annotation == Parameter.empty:
313
314
  return None
@@ -322,6 +323,42 @@ def get_handler_info(host: Any, method_name: str) -> tuple[str, str] | None:
322
323
  return None
323
324
 
324
325
 
326
+ def _resolve_annotation(host: Any, method: Callable, annotation: Any) -> Any:
327
+ if not isinstance(annotation, str):
328
+ return annotation
329
+
330
+ globalns = _annotation_globalns(method)
331
+ localns = _annotation_localns(host)
332
+
333
+ try:
334
+ resolved = eval(annotation, globalns, localns) # noqa: B307
335
+ except Exception:
336
+ resolved = annotation
337
+
338
+ if isinstance(resolved, str):
339
+ # Quoted postponed annotations evaluate to a string first.
340
+ try:
341
+ resolved = eval(resolved, globalns, localns) # noqa: B307
342
+ except Exception:
343
+ if "." in resolved:
344
+ return resolved
345
+ return Parameter.empty
346
+
347
+ return resolved
348
+
349
+
350
+ def _annotation_globalns(method: Callable) -> dict[str, Any]:
351
+ function = getattr(method, "__func__", method)
352
+ return getattr(function, "__globals__", {})
353
+
354
+
355
+ def _annotation_localns(host: Any) -> dict[str, Any]:
356
+ namespace: dict[str, Any] = {}
357
+ for klass in reversed(type(host).__mro__):
358
+ namespace.update(vars(klass))
359
+ return namespace
360
+
361
+
325
362
  def _message_class_name(message_type: Any) -> str | None:
326
363
  if isinstance(message_type, str):
327
364
  return message_type
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iris_pex_embedded_python
3
- Version: 4.0.1b2
3
+ Version: 4.0.1b3
4
4
  Summary: Iris Interoperability based on Embedded Python
5
5
  Author-email: grongier <guillaume.rongier@intersystems.com>
6
6
  License: MIT License
@@ -53,7 +53,7 @@ iop/components/settings.py,sha256=USAKAisdersKlAEIk8HDu_TuYtkO-Sc3an3PXjPcDRA,62
53
53
  iop/messages/__init__.py,sha256=k1AKplpjdqSxM5Gl7bpWAfw93xUgigovlI4SKhwKHRI,355
54
54
  iop/messages/base.py,sha256=ZrVXEz7JrYHnt5b3M7avxcJCB0_OZxm1uWm9gQ4_eAw,1906
55
55
  iop/messages/decorators.py,sha256=CWk08k8U2aTJv7Dx1n2jp8sjZZSCD8NJPoifKLB3W2g,2488
56
- iop/messages/dispatch.py,sha256=Mgz0OHTQDU02Z8qPxl_lks-nlAvW6ADcJkTS4faYE-Q,10459
56
+ iop/messages/dispatch.py,sha256=wfoKyaMOcJTzMEAE5hEHYEt3aiRsaUR_TYmROT2fDrg,11592
57
57
  iop/messages/persistent.py,sha256=ibRhRTqzwGcAqem744KZzHiouUlc8-J3ftB4zyzQYx4,16906
58
58
  iop/messages/serialization.py,sha256=BW0o-7GaceMW7RMOzOJ8g9rKEv28NYnYFwtTLmAf7Yg,9255
59
59
  iop/messages/validation.py,sha256=X6MSWsjLZDuyX1Tfx0TP3T6OI4nj1HZccwR2Z9PSubY,1606
@@ -91,9 +91,9 @@ iop/runtime/remote/director.py,sha256=bkie751GrYLgGs7ApRCowHpSnJA8KupxCOrFDQmjyO
91
91
  iop/runtime/remote/migration.py,sha256=Iboz-Ye7i9xif9bn433GazCF-gtD-HJW3wiUwWS5P6w,1831
92
92
  iop/runtime/remote/settings.py,sha256=P1Hsgld5o57HpSZgPVZzobyjlUmxJj6bstiWvR0JXnc,2144
93
93
  iop/runtime/remote/setup.py,sha256=Tr80F3JJTy7oSUso2jyx0iA_KZayd4MYt9vL0BvPpMA,2600
94
- iris_pex_embedded_python-4.0.1b2.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
95
- iris_pex_embedded_python-4.0.1b2.dist-info/METADATA,sha256=_ECUhPwnkbE0A3kXsGrptdIEBcOaWWuOEFOT9p25n1I,5846
96
- iris_pex_embedded_python-4.0.1b2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
97
- iris_pex_embedded_python-4.0.1b2.dist-info/entry_points.txt,sha256=fzS8ZFsPe8cnpEx208X60DNugCPQmuSloPeg4pyyJDY,42
98
- iris_pex_embedded_python-4.0.1b2.dist-info/top_level.txt,sha256=BM54-OXQ6l2BDtmesWNXckh033s9gcjoO7bfjbwZbxU,4
99
- iris_pex_embedded_python-4.0.1b2.dist-info/RECORD,,
94
+ iris_pex_embedded_python-4.0.1b3.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
95
+ iris_pex_embedded_python-4.0.1b3.dist-info/METADATA,sha256=UFR3F4n2-7iQJSkQ0WLBQYtmNaBwO08z7gZLl-q-_Hg,5846
96
+ iris_pex_embedded_python-4.0.1b3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
97
+ iris_pex_embedded_python-4.0.1b3.dist-info/entry_points.txt,sha256=fzS8ZFsPe8cnpEx208X60DNugCPQmuSloPeg4pyyJDY,42
98
+ iris_pex_embedded_python-4.0.1b3.dist-info/top_level.txt,sha256=BM54-OXQ6l2BDtmesWNXckh033s9gcjoO7bfjbwZbxU,4
99
+ iris_pex_embedded_python-4.0.1b3.dist-info/RECORD,,