diff --git a/docs/requirements.txt b/docs/requirements.txt index ae8adb6..f50f265 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -60,7 +60,7 @@ pygments==2.19.1 # accessible-pygments # furo # sphinx -requests==2.32.4 +requests==2.33.0 # via sphinx roman-numerals==4.1.0 # via sphinx diff --git a/json2xml/dicttoxml_fast.py b/json2xml/dicttoxml_fast.py index d356676..99ebbc4 100644 --- a/json2xml/dicttoxml_fast.py +++ b/json2xml/dicttoxml_fast.py @@ -24,9 +24,15 @@ _rust_dicttoxml = None try: - from json2xml_rs import dicttoxml as _rust_dicttoxml # type: ignore[import-not-found] # pragma: no cover - from json2xml_rs import escape_xml_py as rust_escape_xml # type: ignore[import-not-found] # pragma: no cover - from json2xml_rs import wrap_cdata_py as rust_wrap_cdata # type: ignore[import-not-found] # pragma: no cover + from json2xml_rs import ( + dicttoxml as _rust_dicttoxml, # type: ignore[import-not-found] # ty: ignore[unresolved-import] # pragma: no cover + ) + from json2xml_rs import ( + escape_xml_py as rust_escape_xml, # type: ignore[import-not-found] # ty: ignore[unresolved-import] # pragma: no cover + ) + from json2xml_rs import ( + wrap_cdata_py as rust_wrap_cdata, # type: ignore[import-not-found] # ty: ignore[unresolved-import] # pragma: no cover + ) _USE_RUST = True # pragma: no cover LOG.debug("Using Rust backend for dicttoxml") # pragma: no cover except ImportError: # pragma: no cover diff --git a/tests/test_dict2xml.py b/tests/test_dict2xml.py index 1d279f8..b50b54a 100644 --- a/tests/test_dict2xml.py +++ b/tests/test_dict2xml.py @@ -578,7 +578,7 @@ class CustomClass: # Should return the class name for unsupported types # Using type: ignore for intentional test of unsupported type - result = dicttoxml.get_xml_type(CustomClass()) # type: ignore[arg-type] + result = dicttoxml.get_xml_type(CustomClass()) # type: ignore[arg-type] # ty: ignore[invalid-argument-type] assert result == "CustomClass" def test_make_valid_xml_name_invalid_chars(self) -> None: @@ -807,8 +807,8 @@ def patched_get_unique_id(element: str) -> str: this_id = module.make_id(element) # This exercises line 52 return ids[-1] - module.make_id = mock_make_id # type: ignore[assignment] - module.get_unique_id = patched_get_unique_id # type: ignore[assignment] + module.make_id = mock_make_id # type: ignore[assignment] # ty: ignore[invalid-assignment] + module.get_unique_id = patched_get_unique_id # type: ignore[assignment] # ty: ignore[invalid-assignment] try: result = dicttoxml.get_unique_id("test") @@ -874,7 +874,7 @@ class CustomClass: with pytest.raises(TypeError, match="Unsupported data type:"): dicttoxml.convert( - obj=CustomClass(), # type: ignore[arg-type] + obj=CustomClass(), # type: ignore[arg-type] # ty: ignore[invalid-argument-type] ids=None, attr_type=False, item_func=lambda x: "item", @@ -1024,7 +1024,7 @@ def mock_is_primitive(val: Any) -> bool: return True return original_is_primitive(val) - module.is_primitive_type = mock_is_primitive # type: ignore[assignment] + module.is_primitive_type = mock_is_primitive # type: ignore[assignment] # ty: ignore[invalid-assignment] try: item = {"@val": {"test": "data"}} result = dicttoxml.dict2xml_str( diff --git a/tests/test_json2xml.py b/tests/test_json2xml.py index 84c06d3..b08e580 100644 --- a/tests/test_json2xml.py +++ b/tests/test_json2xml.py @@ -56,12 +56,12 @@ def test_read_from_jsonstring(self) -> None: def test_read_from_invalid_string1(self) -> None: with pytest.raises(StringReadError) as pytest_wrapped_e: - readfromstring(1) # type: ignore[arg-type] + readfromstring(1) # type: ignore[arg-type] # ty: ignore[invalid-argument-type] assert pytest_wrapped_e.type == StringReadError def test_read_from_invalid_string2(self) -> None: with pytest.raises(StringReadError) as pytest_wrapped_e: - readfromstring(jsondata=None) # type: ignore[arg-type] + readfromstring(jsondata=None) # type: ignore[arg-type] # ty: ignore[invalid-argument-type] assert pytest_wrapped_e.type == StringReadError def test_read_from_invalid_jsonstring(self) -> None: diff --git a/tests/test_rust_dicttoxml.py b/tests/test_rust_dicttoxml.py index 6efbcef..36e3707 100644 --- a/tests/test_rust_dicttoxml.py +++ b/tests/test_rust_dicttoxml.py @@ -12,8 +12,13 @@ # Check if Rust extension is available try: - from json2xml_rs import dicttoxml as rust_dicttoxml # type: ignore[import-not-found] - from json2xml_rs import escape_xml_py, wrap_cdata_py # type: ignore[import-not-found] + from json2xml_rs import ( + dicttoxml as rust_dicttoxml, # type: ignore[import-not-found] # ty: ignore[unresolved-import] + ) + from json2xml_rs import ( # type: ignore[import-not-found] + escape_xml_py, # ty: ignore[unresolved-import] + wrap_cdata_py, # ty: ignore[unresolved-import] + ) RUST_AVAILABLE = True except ImportError: RUST_AVAILABLE = False diff --git a/tests/test_utils.py b/tests/test_utils.py index f9346f2..4c985e6 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -225,22 +225,22 @@ def test_readfromstring_complex_object(self) -> None: def test_readfromstring_invalid_type_int(self) -> None: """Test reading with integer input.""" with pytest.raises(StringReadError, match="Input is not a proper JSON string"): - readfromstring(123) # type: ignore[arg-type] + readfromstring(123) # type: ignore[arg-type] # ty: ignore[invalid-argument-type] def test_readfromstring_invalid_type_list(self) -> None: """Test reading with list input.""" with pytest.raises(StringReadError, match="Input is not a proper JSON string"): - readfromstring(["not", "a", "string"]) # type: ignore[arg-type] + readfromstring(["not", "a", "string"]) # type: ignore[arg-type] # ty: ignore[invalid-argument-type] def test_readfromstring_invalid_type_dict(self) -> None: """Test reading with dict input.""" with pytest.raises(StringReadError, match="Input is not a proper JSON string"): - readfromstring({"not": "a string"}) # type: ignore[arg-type] + readfromstring({"not": "a string"}) # type: ignore[arg-type] # ty: ignore[invalid-argument-type] def test_readfromstring_invalid_type_none(self) -> None: """Test reading with None input.""" with pytest.raises(StringReadError, match="Input is not a proper JSON string"): - readfromstring(None) # type: ignore[arg-type] + readfromstring(None) # type: ignore[arg-type] # ty: ignore[invalid-argument-type] def test_readfromstring_invalid_json_syntax(self) -> None: """Test reading string with invalid JSON syntax."""