Skip to content

[xmltodict] Fix regression in postprocessor - #16616

Draft
claui wants to merge 1 commit into
python:mainfrom
claui:xmltodict-postprocessor
Draft

claui wants to merge 1 commit into
python:mainfrom
claui:xmltodict-postprocessor

Conversation

@claui

@claui claui commented Oct 25, 2026

Copy link
Copy Markdown

Overview

PR #14695 added a type signature for the postprocessor Callable but failed to take into account that upstream has a feature where that Callable may return None, and upstream interprets that as “throw away the node entirely in post-processing.” That oversight caused a typechecking regression for all clients who are using this feature.

This PR relaxes the return value for postprocessor so instead of:

tuple[str, _AttrValue]

it can return None to declare that it wants the node gone:

tuple[str, _AttrValue] | None

That way, clients can now use that feature again, just like they used to in types-xmltodict 0.15.0.20250907 and earlier.

Relevant upstream code

For reference, the “throw away this node” upstream feature is implemented here:

That feature has existed pre-1.0, and is still around today.

Commit 15bc02e (PR python#14695 on GitHub [1]) added a type signature for the
`postprocessor` Callable but failed to take into account that upstream
has a feature where that Callable may return `None`, and upstream
interprets that as “throw away the node entirely in post-processing.”
See [2] and [3] in the upstream code.

Relax the return value for `postprocessor` so instead of:

```py
tuple[str, _AttrValue]
```

it can return `None`:

```py
tuple[str, _AttrValue] | None
```

That way, clients can now use that feature again, just like they used to
in types-xmltodict 0.15.0.20250907 and earlier.

[1]: python#14695

[2]: https://github.com/martinblech/xmltodict/blob/v1.0.4/xmltodict.py#L93-L97

[3]: https://github.com/martinblech/xmltodict/blob/v1.0.4/xmltodict.py#L160-L162
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@claui
claui marked this pull request as draft October 25, 2026 22:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant