iris-pex-embedded-python 3.4.0b12__py3-none-any.whl → 3.4.0b14__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.

Potentially problematic release.


This version of iris-pex-embedded-python might be problematic. Click here for more details.

iop/_serialization.py CHANGED
@@ -8,7 +8,7 @@ from dataclasses import asdict, is_dataclass
8
8
  from typing import Any, Dict, Type
9
9
 
10
10
  import iris
11
- from pydantic import BaseModel, TypeAdapter
11
+ from pydantic import BaseModel, TypeAdapter, ValidationError
12
12
 
13
13
  from iop._message import _PydanticPickleMessage
14
14
  from iop._utils import _Utils
@@ -108,38 +108,42 @@ class MessageSerializer:
108
108
  return classname[:j], classname[j+1:]
109
109
 
110
110
  def dataclass_from_dict(klass: Type, dikt: Dict) -> Any:
111
- field_types = {
112
- key: val.annotation
113
- for key, val in inspect.signature(klass).parameters.items()
114
- }
115
- processed_dict = {}
116
- for key, val in inspect.signature(klass).parameters.items():
117
- if key not in dikt and val.default != val.empty:
118
- processed_dict[key] = val.default
119
- continue
120
-
121
- value = dikt.get(key)
111
+ """Converts a dictionary to a dataclass instance.
112
+ Handles non attended fields and nested dataclasses."""
113
+
114
+ def process_field(value: Any, field_type: Type) -> Any:
122
115
  if value is None:
123
- processed_dict[key] = None
116
+ return None
117
+ if is_dataclass(field_type):
118
+ return dataclass_from_dict(field_type, value)
119
+ if field_type != inspect.Parameter.empty:
120
+ try:
121
+ return TypeAdapter(field_type).validate_python(value)
122
+ except ValidationError:
123
+ return value
124
+ return value
125
+
126
+ # Get field definitions from class signature
127
+ fields = inspect.signature(klass).parameters
128
+ field_dict = {}
129
+
130
+ # Process each field
131
+ for field_name, field_info in fields.items():
132
+ if field_name not in dikt:
133
+ if field_info.default != field_info.empty:
134
+ field_dict[field_name] = field_info.default
124
135
  continue
125
-
126
- try:
127
- field_type = field_types[key]
128
- if field_type != inspect.Parameter.empty:
129
- adapter = TypeAdapter(field_type)
130
- processed_dict[key] = adapter.validate_python(value)
131
- else:
132
- processed_dict[key] = value
133
- except Exception:
134
- processed_dict[key] = value
135
-
136
- instance = klass(
137
- **processed_dict
138
- )
139
- # handle any extra fields
140
- for k, v in dikt.items():
141
- if k not in processed_dict:
142
- setattr(instance, k, v)
136
+
137
+ field_dict[field_name] = process_field(dikt[field_name], field_info.annotation)
138
+
139
+ # Create instance
140
+ instance = klass(**field_dict)
141
+
142
+ # Add any extra fields not in the dataclass definition
143
+ for key, value in dikt.items():
144
+ if key not in field_dict:
145
+ setattr(instance, key, value)
146
+
143
147
  return instance
144
148
 
145
149
  def dataclass_to_dict(instance: Any) -> Dict:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: iris_pex_embedded_python
3
- Version: 3.4.0b12
3
+ Version: 3.4.0b14
4
4
  Summary: Iris Interoperability based on Embedded Python
5
5
  Author-email: grongier <guillaume.rongier@intersystems.com>
6
6
  License: MIT License
@@ -49,6 +49,7 @@ Requires-Dist: xmltodict>=0.12.0
49
49
  Requires-Dist: iris-embedded-python-wrapper>=0.0.6
50
50
  Requires-Dist: setuptools>=40.8.0
51
51
  Requires-Dist: jsonpath-ng>=1.7.0
52
+ Dynamic: license-file
52
53
 
53
54
  # IoP (Interoperability On Python)
54
55
 
@@ -109,7 +109,7 @@ iop/_message_validator.py,sha256=K6FxLe72gBHQXZTLVrFw87rABGM0F6CTaNtZ2MqJoss,140
109
109
  iop/_outbound_adapter.py,sha256=YTAhLrRf9chEAd53mV6KKbpaHOKNOKJHoGgj5wakRR0,726
110
110
  iop/_private_session_duplex.py,sha256=mzlFABh-ly51X1uSWw9YwQbktfMvuNdp2ALlRvlDow4,5152
111
111
  iop/_private_session_process.py,sha256=todprfYFSDr-h-BMvWL_IGC6wbQqkMy3mPHWEWCUSE0,1686
112
- iop/_serialization.py,sha256=Uf6PzvOGuzzr3_29KkFpvU_NooVx6unkU6EqHMx7r3A,5900
112
+ iop/_serialization.py,sha256=EEhPbRpgODsGEt3RMiThr5g7Ox6lOT28XFQeAQq2eik,6162
113
113
  iop/_utils.py,sha256=jj1UZHVXYg5uB08E0ETKfpmXQX-TWYSdPl4BO43k2RY,19976
114
114
  iop/cls/IOP/BusinessOperation.cls,sha256=lrymqZ8wHl5kJjXwdjbQVs5sScV__yIWGh-oGbiB_X0,914
115
115
  iop/cls/IOP/BusinessProcess.cls,sha256=s3t38w1ykHqM26ETcbCYLt0ocjZyVVahm-_USZkuJ1E,2855
@@ -133,11 +133,11 @@ iop/cls/IOP/PrivateSession/Message/Start.cls,sha256=uk-WTe66GicCshgmVy3F5ugHiAyP
133
133
  iop/cls/IOP/PrivateSession/Message/Stop.cls,sha256=7g3gKFUjNg0WXBLuWnj-VnCs5G6hSE09YTzGEp0zbGc,1390
134
134
  iop/cls/IOP/Service/WSGI.cls,sha256=VLNCXEwmHW9dBnE51uGE1nvGX6T4HjhqePT3LVhsjAE,10440
135
135
  iop/wsgi/handlers.py,sha256=NrFLo_YbAh-x_PlWhAiWkQnUUN2Ss9HoEm63dDWCBpQ,2947
136
+ iris_pex_embedded_python-3.4.0b14.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
136
137
  irisnative/_IRISNative.py,sha256=HQ4nBhc8t8_5OtxdMG-kx1aa-T1znf2I8obZOPLOPzg,665
137
138
  irisnative/__init__.py,sha256=6YmvBLQSURsCPKaNg7LK-xpo4ipDjrlhKuwdfdNb3Kg,341
138
- iris_pex_embedded_python-3.4.0b12.dist-info/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
139
- iris_pex_embedded_python-3.4.0b12.dist-info/METADATA,sha256=bY-lfujYllhst8-l3Yt74LC4KPxN-3M0u2PAdfAvONs,4398
140
- iris_pex_embedded_python-3.4.0b12.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
141
- iris_pex_embedded_python-3.4.0b12.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
142
- iris_pex_embedded_python-3.4.0b12.dist-info/top_level.txt,sha256=VWDlX4YF4qFVRGrG3-Gs0kgREol02i8gIpsHNbhfFPw,42
143
- iris_pex_embedded_python-3.4.0b12.dist-info/RECORD,,
139
+ iris_pex_embedded_python-3.4.0b14.dist-info/METADATA,sha256=5V_wbU1xuYzxYqKuGcIT-fpGh6he_9n7b0uWwCeQ9JQ,4420
140
+ iris_pex_embedded_python-3.4.0b14.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
141
+ iris_pex_embedded_python-3.4.0b14.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
142
+ iris_pex_embedded_python-3.4.0b14.dist-info/top_level.txt,sha256=VWDlX4YF4qFVRGrG3-Gs0kgREol02i8gIpsHNbhfFPw,42
143
+ iris_pex_embedded_python-3.4.0b14.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.0.0)
2
+ Generator: setuptools (77.0.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5