Skip to content

Commit 5f332ab

Browse files
authored
Bump xmltodict to v1.0.2 (#692)
* Bump xmltodict to v1.0.2 * Stay closer to old implementation and manage what changed from xmltodict output * Ignore faulty typing in xmltodict types
1 parent abc80ca commit 5f332ab

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ repos:
1414
"httpx==0.28.1",
1515
"orjson==3.11.5",
1616
"packaging==25.0",
17-
"types-xmltodict==v0.15.0.20250907"
17+
"types-xmltodict==v1.0.1.20250920"
1818
]
1919
exclude: ^tests/

axis/models/event.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,15 @@ def _decode_from_bytes(cls, data: bytes) -> Self:
195195
data,
196196
# attr_prefix="",
197197
process_namespaces=True,
198-
namespaces=XML_NAMESPACES,
198+
namespaces=XML_NAMESPACES, # type: ignore[arg-type]
199199
)
200200

201-
if raw.get("MetadataStream") is None:
201+
# Normalize the ONVIF metadata root: always use a dict, drop any stray
202+
# XML namespace attribute ("@xmlns") added by xmltodict, and bail out
203+
# early if the payload is empty.
204+
stream = raw.get("MetadataStream") or {}
205+
stream.pop("@xmlns", None)
206+
if not stream:
202207
return cls._decode_from_dict({})
203208

204209
topic = traverse(raw, TOPIC)

axis/models/event_instance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def decode(cls, bytes_data: bytes) -> Self:
166166
bytes_data,
167167
# attr_prefix="",
168168
dict_constructor=dict, # Use dict rather than ordered_dict
169-
namespaces=NAMESPACES, # Replace or remove defined namespaces
169+
namespaces=NAMESPACES, # type: ignore[arg-type] # Replace or remove defined namespaces
170170
process_namespaces=True,
171171
)
172172
raw_events = traverse(data, EVENT_INSTANCE) # Move past the irrelevant keys

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ requirements = [
3232
"httpx==0.28.1",
3333
"orjson==3.11.5",
3434
"packaging==25.0",
35-
"xmltodict==0.15.1",
35+
"xmltodict==1.0.2",
3636
]
3737
requirements-test = [
3838
"mypy==1.19.1",
@@ -42,7 +42,7 @@ requirements-test = [
4242
"pytest-cov==7.0.0",
4343
"respx==0.22.0",
4444
"ruff==0.14.10",
45-
"types-xmltodict==v0.15.0.20250907",
45+
"types-xmltodict==v1.0.1.20250920",
4646
]
4747
requirements-dev = [
4848
"pre-commit==4.5.1"

0 commit comments

Comments
 (0)