fix(ascleandict): recurse to clean the dict#6
Merged
MrKevinWeiss merged 1 commit intomasterfrom Dec 4, 2025
Merged
Conversation
There was a problem hiding this comment.
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_valuehelper 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.
92f8e4c to
5fca136
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.