Skip to content

Commit f7f9f71

Browse files
committed
fix: mypy types issue
1 parent 0adfd22 commit f7f9f71

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

tests/test_dict2xml.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
from json2xml import dicttoxml
88

99
if TYPE_CHECKING:
10-
pass
10+
from _pytest.capture import CaptureFixture
11+
from _pytest.fixtures import FixtureRequest
12+
from _pytest.logging import LogCaptureFixture
13+
from _pytest.monkeypatch import MonkeyPatch
14+
from pytest_mock.plugin import MockerFixture
1115

1216

1317
class TestDict2xml:
@@ -522,7 +526,7 @@ def test_list_to_xml_with_mixed_items(self) -> None:
522526

523527
def test_list_to_xml_with_empty_list(self) -> None:
524528
"""Test list to XML with empty list."""
525-
data = {"items": []}
529+
data: dict[str, list[Any]] = {"items": []}
526530
result = dicttoxml.dicttoxml(data, root=False, attr_type=False, item_wrap=True)
527531
assert result == b"<items></items>"
528532

@@ -574,13 +578,14 @@ class CustomClass:
574578
pass
575579

576580
# Should return the class name for unsupported types
577-
result = dicttoxml.get_xml_type(CustomClass())
581+
# Using type: ignore for intentional test of unsupported type
582+
result = dicttoxml.get_xml_type(CustomClass()) # type: ignore[arg-type]
578583
assert result == "CustomClass"
579584

580585
def test_make_valid_xml_name_invalid_chars(self) -> None:
581586
"""Test make_valid_xml_name with invalid XML characters."""
582587
key = "<invalid>key"
583-
attr = {}
588+
attr: dict[str, Any] = {}
584589
new_key, new_attr = dicttoxml.make_valid_xml_name(key, attr)
585590
assert new_key == "key"
586591
assert new_attr == {"name": "&lt;invalid&gt;key"}
@@ -781,7 +786,7 @@ def test_get_unique_id_with_duplicates(self) -> None:
781786
call_count = 0
782787
original_make_id = module.make_id
783788

784-
def mock_make_id(element, start=100000, end=999999):
789+
def mock_make_id(element: str, start: int = 100000, end: int = 999999) -> str:
785790
nonlocal call_count
786791
call_count += 1
787792
if call_count == 1:
@@ -870,7 +875,7 @@ class CustomClass:
870875

871876
with pytest.raises(TypeError, match="Unsupported data type:"):
872877
dicttoxml.convert(
873-
obj=CustomClass(),
878+
obj=CustomClass(), # type: ignore[arg-type]
874879
ids=None,
875880
attr_type=False,
876881
item_func=lambda x: "item",
@@ -1015,7 +1020,7 @@ def test_dict2xml_str_with_primitive_dict_rawitem(self) -> None:
10151020
import json2xml.dicttoxml as module
10161021
original_is_primitive = module.is_primitive_type
10171022

1018-
def mock_is_primitive(val):
1023+
def mock_is_primitive(val: Any) -> bool:
10191024
if isinstance(val, dict) and val == {"test": "data"}:
10201025
return True
10211026
return original_is_primitive(val)

0 commit comments

Comments
 (0)