stinger-python-utils 0.1.5__tar.gz → 0.1.7__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.
@@ -0,0 +1,4 @@
1
+ {
2
+ "python-envs.defaultEnvManager": "ms-python.python:system",
3
+ "python-envs.pythonProjects": []
4
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stinger-python-utils
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: Common utilities for Stinger Python services.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "stinger-python-utils"
7
- version = "0.1.5"
7
+ version = "0.1.7"
8
8
  description = "Common utilities for Stinger Python services."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -4,6 +4,7 @@ from typing import Union, Optional
4
4
  import uuid
5
5
  from .return_codes import MethodReturnCode
6
6
 
7
+
7
8
  class MessageCreator:
8
9
 
9
10
  @classmethod
@@ -13,6 +14,7 @@ class MessageCreator:
13
14
  payload=payload.model_dump_json(by_alias=True).encode("utf-8"),
14
15
  qos=1,
15
16
  retain=False,
17
+ content_type="application/json",
16
18
  )
17
19
 
18
20
  @classmethod
@@ -25,6 +27,7 @@ class MessageCreator:
25
27
  qos=1,
26
28
  retain=True,
27
29
  message_expiry_interval=expiry_seconds,
30
+ content_type="application/json",
28
31
  )
29
32
 
30
33
  @classmethod
@@ -38,7 +41,11 @@ class MessageCreator:
38
41
  """
39
42
  This could be used for a response to a request, but where there was an error fulfilling the request.
40
43
  """
41
- rc = return_code.value if isinstance(return_code, MethodReturnCode) else return_code
44
+ rc = (
45
+ return_code.value
46
+ if isinstance(return_code, MethodReturnCode)
47
+ else return_code
48
+ )
42
49
  msg_obj = Message(
43
50
  topic=topic,
44
51
  payload=b"{}",
@@ -50,6 +57,7 @@ class MessageCreator:
50
57
  else correlation_id
51
58
  ),
52
59
  user_properties={"ReturnCode": str(rc)},
60
+ content_type="application/json",
53
61
  )
54
62
  if (
55
63
  debug_info is not None and msg_obj.user_properties is not None
@@ -74,7 +82,11 @@ class MessageCreator:
74
82
  payload = response_obj.encode("utf-8")
75
83
  else:
76
84
  payload = response_obj
77
- rc = return_code.value if isinstance(return_code, MethodReturnCode) else return_code
85
+ rc = (
86
+ return_code.value
87
+ if isinstance(return_code, MethodReturnCode)
88
+ else return_code
89
+ )
78
90
  msg_obj = Message(
79
91
  topic=response_topic,
80
92
  payload=payload,
@@ -86,6 +98,7 @@ class MessageCreator:
86
98
  else correlation_id
87
99
  ),
88
100
  user_properties={"ReturnCode": str(rc)},
101
+ content_type="application/json",
89
102
  )
90
103
  return msg_obj
91
104
 
@@ -124,6 +137,7 @@ class MessageCreator:
124
137
  payload=property_obj.model_dump_json(by_alias=True).encode("utf-8"),
125
138
  qos=1,
126
139
  retain=False,
140
+ content_type="application/json",
127
141
  response_topic=response_topic,
128
142
  correlation_data=(
129
143
  correlation_id.encode("utf-8")
@@ -147,12 +161,17 @@ class MessageCreator:
147
161
  """
148
162
  Creates a message representing a response to a property update request.
149
163
  """
150
- rc = return_code.value if isinstance(return_code, MethodReturnCode) else return_code
164
+ rc = (
165
+ return_code.value
166
+ if isinstance(return_code, MethodReturnCode)
167
+ else return_code
168
+ )
151
169
  msg_obj = Message(
152
170
  topic=response_topic,
153
171
  payload=property_obj.model_dump_json(by_alias=True).encode("utf-8"),
154
172
  qos=1,
155
173
  retain=False,
174
+ content_type="application/json",
156
175
  correlation_data=(
157
176
  correlation_id.encode("utf-8")
158
177
  if isinstance(correlation_id, str)
@@ -185,6 +204,7 @@ class MessageCreator:
185
204
  qos=1,
186
205
  retain=False,
187
206
  response_topic=response_topic,
207
+ content_type="application/json",
188
208
  correlation_data=(
189
209
  correlation_id.encode("utf-8")
190
210
  if isinstance(correlation_id, str)
@@ -20,6 +20,7 @@ class TestSignalMessage:
20
20
  assert message.qos == 1
21
21
  assert message.retain is False
22
22
  assert b'"name":"test"' in message.payload
23
+ assert message.content_type == "application/json"
23
24
 
24
25
 
25
26
  class TestStatusMessage:
@@ -32,6 +33,7 @@ class TestStatusMessage:
32
33
  assert message.qos == 1
33
34
  assert message.retain is True
34
35
  assert message.message_expiry_interval == 3600
36
+ assert message.content_type == "application/json"
35
37
 
36
38
 
37
39
  class TestErrorResponseMessage:
@@ -48,6 +50,7 @@ class TestErrorResponseMessage:
48
50
  assert message.retain is False
49
51
  assert message.user_properties["ReturnCode"] == "500"
50
52
  assert message.correlation_data == b"abc-123"
53
+ assert message.content_type == "application/json"
51
54
 
52
55
  def test_error_response_with_bytes_correlation_id(self):
53
56
  """Test error response with bytes correlation ID"""
@@ -59,6 +62,7 @@ class TestErrorResponseMessage:
59
62
 
60
63
  assert message.correlation_data == b"xyz-789"
61
64
  assert message.user_properties["ReturnCode"] == "400"
65
+ assert message.content_type == "application/json"
62
66
 
63
67
  def test_error_response_with_debug_info(self):
64
68
  """Test error response includes debug info"""
@@ -69,6 +73,7 @@ class TestErrorResponseMessage:
69
73
  )
70
74
 
71
75
  assert message.user_properties["DebugInfo"] == "Something went wrong"
76
+ assert message.content_type == "application/json"
72
77
 
73
78
 
74
79
  class TestResponseMessage:
@@ -86,6 +91,7 @@ class TestResponseMessage:
86
91
  assert message.qos == 1
87
92
  assert message.user_properties["ReturnCode"] == "200"
88
93
  assert message.correlation_data == b"req-123"
94
+ assert message.content_type == "application/json"
89
95
 
90
96
  def test_response_message_with_string(self):
91
97
  """Test response message with string payload"""
@@ -96,6 +102,7 @@ class TestResponseMessage:
96
102
  )
97
103
 
98
104
  assert message.payload == b"success"
105
+ assert message.content_type == "application/json"
99
106
 
100
107
  def test_response_message_with_bytes(self):
101
108
  """Test response message with bytes payload"""
@@ -106,6 +113,7 @@ class TestResponseMessage:
106
113
  )
107
114
 
108
115
  assert message.payload == b"binary data"
116
+ assert message.content_type == "application/json"
109
117
 
110
118
 
111
119
  class TestPropertyStateMessage:
@@ -147,6 +155,7 @@ class TestPropertyUpdateRequestMessage:
147
155
  assert message.response_topic == "property/response"
148
156
  assert message.user_properties["PropertyVersion"] == "1.0"
149
157
  assert message.correlation_data == b"update-123"
158
+ assert message.content_type == "application/json"
150
159
 
151
160
 
152
161
  class TestPropertyResponseMessage:
@@ -165,6 +174,7 @@ class TestPropertyResponseMessage:
165
174
  assert message.user_properties["ReturnCode"] == "200"
166
175
  assert message.user_properties["PropertyVersion"] == "1.0"
167
176
  assert message.correlation_data == b"update-123"
177
+ assert message.content_type == "application/json"
168
178
 
169
179
  def test_property_response_message_with_debug_info(self):
170
180
  """Test property response message with debug info"""
@@ -178,6 +188,7 @@ class TestPropertyResponseMessage:
178
188
  )
179
189
 
180
190
  assert message.user_properties["DebugInfo"] == "Update failed"
191
+ assert message.content_type == "application/json"
181
192
 
182
193
 
183
194
  class TestRequestMessage:
@@ -194,6 +205,7 @@ class TestRequestMessage:
194
205
  assert message.response_topic == "response/topic"
195
206
  assert message.correlation_data is not None
196
207
  assert len(message.correlation_data) > 0
208
+ assert message.content_type == "application/json"
197
209
 
198
210
  def test_request_message_with_correlation_id(self):
199
211
  """Test request message with provided correlation ID"""
@@ -206,3 +218,4 @@ class TestRequestMessage:
206
218
  )
207
219
 
208
220
  assert message.correlation_data == b"req-456"
221
+ assert message.content_type == "application/json"
@@ -1270,35 +1270,9 @@ wheels = [
1270
1270
  { url = "https://files.pythonhosted.org/packages/84/25/d9db8be44e205a124f6c98bc0324b2bb149b7431c53877fc6d1038dddaf5/pytokens-0.3.0-py3-none-any.whl", hash = "sha256:95b2b5eaf832e469d141a378872480ede3f251a5a5041b8ec6e581d3ac71bbf3", size = 12195, upload-time = "2025-11-05T13:36:33.183Z" },
1271
1271
  ]
1272
1272
 
1273
- [[package]]
1274
- name = "ruff"
1275
- version = "0.14.10"
1276
- source = { registry = "https://pypi.org/simple" }
1277
- sdist = { url = "https://files.pythonhosted.org/packages/57/08/52232a877978dd8f9cf2aeddce3e611b40a63287dfca29b6b8da791f5e8d/ruff-0.14.10.tar.gz", hash = "sha256:9a2e830f075d1a42cd28420d7809ace390832a490ed0966fe373ba288e77aaf4", size = 5859763, upload-time = "2025-12-18T19:28:57.98Z" }
1278
- wheels = [
1279
- { url = "https://files.pythonhosted.org/packages/60/01/933704d69f3f05ee16ef11406b78881733c186fe14b6a46b05cfcaf6d3b2/ruff-0.14.10-py3-none-linux_armv6l.whl", hash = "sha256:7a3ce585f2ade3e1f29ec1b92df13e3da262178df8c8bdf876f48fa0e8316c49", size = 13527080, upload-time = "2025-12-18T19:29:25.642Z" },
1280
- { url = "https://files.pythonhosted.org/packages/df/58/a0349197a7dfa603ffb7f5b0470391efa79ddc327c1e29c4851e85b09cc5/ruff-0.14.10-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:674f9be9372907f7257c51f1d4fc902cb7cf014b9980152b802794317941f08f", size = 13797320, upload-time = "2025-12-18T19:29:02.571Z" },
1281
- { url = "https://files.pythonhosted.org/packages/7b/82/36be59f00a6082e38c23536df4e71cdbc6af8d7c707eade97fcad5c98235/ruff-0.14.10-py3-none-macosx_11_0_arm64.whl", hash = "sha256:d85713d522348837ef9df8efca33ccb8bd6fcfc86a2cde3ccb4bc9d28a18003d", size = 12918434, upload-time = "2025-12-18T19:28:51.202Z" },
1282
- { url = "https://files.pythonhosted.org/packages/a6/00/45c62a7f7e34da92a25804f813ebe05c88aa9e0c25e5cb5a7d23dd7450e3/ruff-0.14.10-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6987ebe0501ae4f4308d7d24e2d0fe3d7a98430f5adfd0f1fead050a740a3a77", size = 13371961, upload-time = "2025-12-18T19:29:04.991Z" },
1283
- { url = "https://files.pythonhosted.org/packages/40/31/a5906d60f0405f7e57045a70f2d57084a93ca7425f22e1d66904769d1628/ruff-0.14.10-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:16a01dfb7b9e4eee556fbfd5392806b1b8550c9b4a9f6acd3dbe6812b193c70a", size = 13275629, upload-time = "2025-12-18T19:29:21.381Z" },
1284
- { url = "https://files.pythonhosted.org/packages/3e/60/61c0087df21894cf9d928dc04bcd4fb10e8b2e8dca7b1a276ba2155b2002/ruff-0.14.10-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7165d31a925b7a294465fa81be8c12a0e9b60fb02bf177e79067c867e71f8b1f", size = 14029234, upload-time = "2025-12-18T19:29:00.132Z" },
1285
- { url = "https://files.pythonhosted.org/packages/44/84/77d911bee3b92348b6e5dab5a0c898d87084ea03ac5dc708f46d88407def/ruff-0.14.10-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:c561695675b972effb0c0a45db233f2c816ff3da8dcfbe7dfc7eed625f218935", size = 15449890, upload-time = "2025-12-18T19:28:53.573Z" },
1286
- { url = "https://files.pythonhosted.org/packages/e9/36/480206eaefa24a7ec321582dda580443a8f0671fdbf6b1c80e9c3e93a16a/ruff-0.14.10-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4bb98fcbbc61725968893682fd4df8966a34611239c9fd07a1f6a07e7103d08e", size = 15123172, upload-time = "2025-12-18T19:29:23.453Z" },
1287
- { url = "https://files.pythonhosted.org/packages/5c/38/68e414156015ba80cef5473d57919d27dfb62ec804b96180bafdeaf0e090/ruff-0.14.10-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f24b47993a9d8cb858429e97bdf8544c78029f09b520af615c1d261bf827001d", size = 14460260, upload-time = "2025-12-18T19:29:27.808Z" },
1288
- { url = "https://files.pythonhosted.org/packages/b3/19/9e050c0dca8aba824d67cc0db69fb459c28d8cd3f6855b1405b3f29cc91d/ruff-0.14.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:59aabd2e2c4fd614d2862e7939c34a532c04f1084476d6833dddef4afab87e9f", size = 14229978, upload-time = "2025-12-18T19:29:11.32Z" },
1289
- { url = "https://files.pythonhosted.org/packages/51/eb/e8dd1dd6e05b9e695aa9dd420f4577debdd0f87a5ff2fedda33c09e9be8c/ruff-0.14.10-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:213db2b2e44be8625002dbea33bb9c60c66ea2c07c084a00d55732689d697a7f", size = 14338036, upload-time = "2025-12-18T19:29:09.184Z" },
1290
- { url = "https://files.pythonhosted.org/packages/6a/12/f3e3a505db7c19303b70af370d137795fcfec136d670d5de5391e295c134/ruff-0.14.10-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b914c40ab64865a17a9a5b67911d14df72346a634527240039eb3bd650e5979d", size = 13264051, upload-time = "2025-12-18T19:29:13.431Z" },
1291
- { url = "https://files.pythonhosted.org/packages/08/64/8c3a47eaccfef8ac20e0484e68e0772013eb85802f8a9f7603ca751eb166/ruff-0.14.10-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1484983559f026788e3a5c07c81ef7d1e97c1c78ed03041a18f75df104c45405", size = 13283998, upload-time = "2025-12-18T19:29:06.994Z" },
1292
- { url = "https://files.pythonhosted.org/packages/12/84/534a5506f4074e5cc0529e5cd96cfc01bb480e460c7edf5af70d2bcae55e/ruff-0.14.10-py3-none-musllinux_1_2_i686.whl", hash = "sha256:c70427132db492d25f982fffc8d6c7535cc2fd2c83fc8888f05caaa248521e60", size = 13601891, upload-time = "2025-12-18T19:28:55.811Z" },
1293
- { url = "https://files.pythonhosted.org/packages/0d/1e/14c916087d8598917dbad9b2921d340f7884824ad6e9c55de948a93b106d/ruff-0.14.10-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5bcf45b681e9f1ee6445d317ce1fa9d6cba9a6049542d1c3d5b5958986be8830", size = 14336660, upload-time = "2025-12-18T19:29:16.531Z" },
1294
- { url = "https://files.pythonhosted.org/packages/f2/1c/d7b67ab43f30013b47c12b42d1acd354c195351a3f7a1d67f59e54227ede/ruff-0.14.10-py3-none-win32.whl", hash = "sha256:104c49fc7ab73f3f3a758039adea978869a918f31b73280db175b43a2d9b51d6", size = 13196187, upload-time = "2025-12-18T19:29:19.006Z" },
1295
- { url = "https://files.pythonhosted.org/packages/fb/9c/896c862e13886fae2af961bef3e6312db9ebc6adc2b156fe95e615dee8c1/ruff-0.14.10-py3-none-win_amd64.whl", hash = "sha256:466297bd73638c6bdf06485683e812db1c00c7ac96d4ddd0294a338c62fdc154", size = 14661283, upload-time = "2025-12-18T19:29:30.16Z" },
1296
- { url = "https://files.pythonhosted.org/packages/74/31/b0e29d572670dca3674eeee78e418f20bdf97fa8aa9ea71380885e175ca0/ruff-0.14.10-py3-none-win_arm64.whl", hash = "sha256:e51d046cf6dda98a4633b8a8a771451107413b0f07183b2bef03f075599e44e6", size = 13729839, upload-time = "2025-12-18T19:28:48.636Z" },
1297
- ]
1298
-
1299
1273
  [[package]]
1300
1274
  name = "stinger-python-utils"
1301
- version = "0.1.5"
1275
+ version = "0.1.7"
1302
1276
  source = { editable = "." }
1303
1277
  dependencies = [
1304
1278
  { name = "pydantic", version = "2.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.8'" },
@@ -1320,7 +1294,6 @@ dev = [
1320
1294
  { name = "pytest", version = "8.3.5", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.8.*'" },
1321
1295
  { name = "pytest", version = "8.4.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.9.*'" },
1322
1296
  { name = "pytest", version = "9.0.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" },
1323
- { name = "ruff" },
1324
1297
  ]
1325
1298
 
1326
1299
  [package.metadata]
@@ -1334,7 +1307,6 @@ dev = [
1334
1307
  { name = "black", specifier = ">=23.3.0" },
1335
1308
  { name = "mypy", specifier = ">=1.4.1" },
1336
1309
  { name = "pytest", specifier = ">=7.0.0" },
1337
- { name = "ruff", specifier = ">=0.14.10" },
1338
1310
  ]
1339
1311
 
1340
1312
  [[package]]