Skip to content

fix(ascleandict): recurse to clean the dict#6

Merged
MrKevinWeiss merged 1 commit intomasterfrom
pr/fix/ascleandict
Dec 4, 2025
Merged

fix(ascleandict): recurse to clean the dict#6
MrKevinWeiss merged 1 commit intomasterfrom
pr/fix/ascleandict

Conversation

@MrKevinWeiss
Copy link
Collaborator

It seems like some deeply nested cases do not get caught. This should make sure we get rid of every empty object, even if the object become empty after a pass.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the ascleandict function to properly handle deeply nested empty structures by adding recursive cleaning logic. Previously, nested objects that became empty after their contents were cleaned were not removed, leading to incomplete cleanup.

Key Changes:

  • Added a new clean_value helper function that recursively processes dictionaries and lists
  • Implemented a while loop to handle cascading cleanup where removing empty values causes parent structures to become empty
  • Enhanced test coverage with new test cases for deeply nested structures and list cleaning

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/lob_hlpr/hlpr.py Implements recursive cleaning logic with clean_value function and cascading cleanup via while loop to remove empty nested structures
tests/test_lob_hlpr.py Adds comprehensive test cases for deeply nested structure cleanup, including multi-level nesting and list element filtering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

It seems like some deeply nested cases do not get caught. This should make sure we get rid of every empty object, even if the object become empty after a pass.
@MrKevinWeiss MrKevinWeiss merged commit 38b610c into master Dec 4, 2025
5 checks passed
@MrKevinWeiss MrKevinWeiss deleted the pr/fix/ascleandict branch December 4, 2025 13:09
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