Skip to content

Treat maps with falsey keys as non-empty - #117

Open
vitalivo wants to merge 1 commit into
drgrib:masterfrom
vitalivo:fix/empty-falsey-keys
Open

vitalivo wants to merge 1 commit into
drgrib:masterfrom
vitalivo:fix/empty-falsey-keys

Conversation

@vitalivo

Copy link
Copy Markdown

DotMap({0: "value"}).empty() returns True because any(self) tests whether any key is truthy. The same happens with False, an empty string, or None as the only key. As a result, addition treats these populated maps as initialization placeholders and returns the replacement value instead of raising TypeError.

Check the mapping length instead. Add regression cases for each falsey key, including the addition behavior and preservation of the existing entry. All four cases fail before the fix.

Validation: the full python -m unittest suite passes on Python 3.10 and 3.14.

@vitalivo vitalivo closed this Sep 12, 2026
@vitalivo vitalivo reopened this Sep 12, 2026
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