[xmltodict] Fix false positive for namespaces with None values (#15245)

This commit is contained in:
Emmanuel Ferdman
2026-01-12 17:21:13 +02:00
committed by GitHub
parent 47c0e2d5aa
commit f0344b83b3
2 changed files with 11 additions and 5 deletions
@@ -0,0 +1,6 @@
from __future__ import annotations
import xmltodict
ns: dict[str, None] = {"http://example.com/": None}
xmltodict.parse("<a/>", namespaces=ns)
+5 -5
View File
@@ -25,7 +25,7 @@ class _DictSAXHandler:
dict_constructor: type
strip_whitespace: bool
namespace_separator: str
namespaces: dict[str, str] | None
namespaces: Mapping[str, str | None] | None
namespace_declarations: dict[str, str]
force_list: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] | None
comment_key: str
@@ -42,7 +42,7 @@ class _DictSAXHandler:
dict_constructor: type = ...,
strip_whitespace: bool = True,
namespace_separator: str = ":",
namespaces: dict[str, str] | None = None,
namespaces: Mapping[str, str | None] | None = None,
force_list: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] | None = None,
comment_key: str = "#comment",
) -> None: ...
@@ -72,7 +72,7 @@ def parse(
postprocessor: Callable[[list[tuple[str, _AttrDict | None]], str, _AttrValue], tuple[str, _AttrValue]] | None = None,
dict_constructor: type = ...,
strip_whitespace: bool = True,
namespaces: dict[str, str] | None = None,
namespaces: Mapping[str, str | None] | None = None,
force_list: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] | None = None,
comment_key: str = "#comment",
) -> dict[str, Any]: ...
@@ -95,7 +95,7 @@ def unparse(
newl: str = "\n",
indent: str | int = "\t",
namespace_separator: str = ":",
namespaces: Mapping[str, str] | None = None,
namespaces: Mapping[str, str | None] | None = None,
expand_iter: str | None = None,
) -> None: ...
@overload
@@ -117,6 +117,6 @@ def unparse(
newl: str = "\n",
indent: str | int = "\t",
namespace_separator: str = ":",
namespaces: Mapping[str, str] | None = None,
namespaces: Mapping[str, str | None] | None = None,
expand_iter: str | None = None,
) -> str: ...