Skip to content

Commit 937978b

Browse files
committed
fix: resolve ruff and ty lint errors for CI
- Add noqa comment for E402 on intentional late import in dicttoxml_fast.py - Fix import sorting in test_rust_dicttoxml.py - Add type ignore comments for optional Rust extension imports
1 parent 71c9642 commit 937978b

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

json2xml/dicttoxml_fast.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
_rust_dicttoxml = None
2525

2626
try:
27-
from json2xml_rs import dicttoxml as _rust_dicttoxml
28-
from json2xml_rs import escape_xml_py as rust_escape_xml
29-
from json2xml_rs import wrap_cdata_py as rust_wrap_cdata
27+
from json2xml_rs import dicttoxml as _rust_dicttoxml # type: ignore[import-not-found]
28+
from json2xml_rs import escape_xml_py as rust_escape_xml # type: ignore[import-not-found]
29+
from json2xml_rs import wrap_cdata_py as rust_wrap_cdata # type: ignore[import-not-found]
3030
_USE_RUST = True
3131
LOG.debug("Using Rust backend for dicttoxml")
3232
except ImportError:
@@ -35,7 +35,7 @@
3535
rust_wrap_cdata = None
3636

3737
# Import the pure Python implementation as fallback
38-
from json2xml import dicttoxml as _py_dicttoxml
38+
from json2xml import dicttoxml as _py_dicttoxml # noqa: E402
3939

4040

4141
def is_rust_available() -> bool:

tests/test_rust_dicttoxml.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@
1010

1111
# Check if Rust extension is available
1212
try:
13-
from json2xml_rs import dicttoxml as rust_dicttoxml
14-
from json2xml_rs import escape_xml_py, wrap_cdata_py
13+
from json2xml_rs import dicttoxml as rust_dicttoxml # type: ignore[import-not-found]
14+
from json2xml_rs import escape_xml_py, wrap_cdata_py # type: ignore[import-not-found]
1515
RUST_AVAILABLE = True
1616
except ImportError:
1717
RUST_AVAILABLE = False
1818

1919
from json2xml import dicttoxml as py_dicttoxml
20-
from json2xml.dicttoxml_fast import dicttoxml as fast_dicttoxml, is_rust_available, get_backend
21-
20+
from json2xml.dicttoxml_fast import (
21+
dicttoxml as fast_dicttoxml,
22+
)
23+
from json2xml.dicttoxml_fast import (
24+
get_backend,
25+
is_rust_available,
26+
)
2227

2328
# Skip all tests if Rust is not available
2429
pytestmark = pytest.mark.skipif(not RUST_AVAILABLE, reason="Rust extension not installed")

0 commit comments

Comments
 (0)