hostel-protocol-python 0.3.0__tar.gz → 0.3.2__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.
Files changed (20) hide show
  1. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/PKG-INFO +1 -1
  2. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/pyproject.toml +1 -1
  3. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/protocol/converter.py +19 -0
  4. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/.github/workflows/ci.yml +0 -0
  5. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/.github/workflows/publish.yml +0 -0
  6. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/.gitignore +0 -0
  7. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/Makefile +0 -0
  8. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/client/__init__.py +0 -0
  9. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/client/client.py +0 -0
  10. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/protocol/__init__.py +0 -0
  11. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/protocol/models.py +0 -0
  12. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/py.typed +0 -0
  13. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/transport/__init__.py +0 -0
  14. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/transport/transport.py +0 -0
  15. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/src/hostel/transport/zeromq.py +0 -0
  16. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/__init__.py +0 -0
  17. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/test_client.py +0 -0
  18. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/test_converter.py +0 -0
  19. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/test_models.py +0 -0
  20. {hostel_protocol_python-0.3.0 → hostel_protocol_python-0.3.2}/tests/test_transport.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hostel-protocol-python
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Pydantic models, transport and client for the Hostel protocol
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: hostel-protocol>=0.3.0
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "hostel-protocol-python"
7
- version = "0.3.0"
7
+ version = "0.3.2"
8
8
  description = "Pydantic models, transport and client for the Hostel protocol"
9
9
  requires-python = ">=3.12"
10
10
  dependencies = [
@@ -98,6 +98,14 @@ _SUB_MSG_FIELDS: dict[type[Message], dict[str, type[Message]]] = {
98
98
  task_pb2.UpdateTaskResponse: {"task": task_pb2.TaskData},
99
99
  }
100
100
 
101
+ # Enum fields: proto class -> {field_name: {int_value: str_value}}
102
+ # Used to convert between proto integer enum values and Pydantic string literals.
103
+ _ENUM_FIELDS: dict[type[Message], dict[str, dict[int, str]]] = {
104
+ chat_pb2.ChatRequest: {
105
+ "planning_mode": {0: "react", 1: "plan_and_execute"},
106
+ },
107
+ }
108
+
101
109
  # oneof groups: proto class -> {field_name: proto sub-message class}
102
110
  _ONEOF_FIELDS: dict[type[Message], dict[str, type[Message]]] = {
103
111
  chat_pb2.ChatMessage: {
@@ -196,6 +204,7 @@ def _pydantic_to_proto_inner(model: BaseModel, proto_cls: type[Message]) -> Mess
196
204
  repeated_fields = _REPEATED_MSG_FIELDS.get(proto_cls, {})
197
205
  sub_msg_fields = _SUB_MSG_FIELDS.get(proto_cls, {})
198
206
  oneof_fields = _ONEOF_FIELDS.get(proto_cls, {})
207
+ enum_fields = _ENUM_FIELDS.get(proto_cls, {})
199
208
 
200
209
  # Special handling for HostelMessage payload oneof
201
210
  is_envelope = proto_cls is message_pb2.HostelMessage
@@ -252,6 +261,11 @@ def _pydantic_to_proto_inner(model: BaseModel, proto_cls: type[Message]) -> Mess
252
261
  if child_pydantic_cls and isinstance(value, child_pydantic_cls):
253
262
  getattr(proto, field_name).CopyFrom(_pydantic_to_proto_inner(value, child_proto_cls))
254
263
 
264
+ # Enum fields (string literal -> int)
265
+ elif field_name in enum_fields:
266
+ str_to_int = {v: k for k, v in enum_fields[field_name].items()}
267
+ setattr(proto, field_name, str_to_int[value])
268
+
255
269
  # Scalar fields
256
270
  else:
257
271
  setattr(proto, field_name, value)
@@ -280,6 +294,7 @@ def _proto_to_pydantic_inner(proto: Message, pydantic_cls: type[BaseModel]) -> B
280
294
  repeated_fields = _REPEATED_MSG_FIELDS.get(proto_cls, {})
281
295
  sub_msg_fields = _SUB_MSG_FIELDS.get(proto_cls, {})
282
296
  oneof_fields = _ONEOF_FIELDS.get(proto_cls, {})
297
+ enum_fields = _ENUM_FIELDS.get(proto_cls, {})
283
298
 
284
299
  is_envelope = proto_cls is message_pb2.HostelMessage
285
300
 
@@ -361,6 +376,10 @@ def _proto_to_pydantic_inner(proto: Message, pydantic_cls: type[BaseModel]) -> B
361
376
  else:
362
377
  kwargs[field_name] = None
363
378
 
379
+ # Enum fields (int -> string literal)
380
+ elif field_name in enum_fields:
381
+ kwargs[field_name] = enum_fields[field_name][getattr(proto, field_name)]
382
+
364
383
  # Scalar fields
365
384
  else:
366
385
  kwargs[field_name] = getattr(proto, field_name)