Skip to content

Conversation

@aseembits93
Copy link
Contributor

@aseembits93 aseembits93 commented Sep 3, 2025

TODO: write for all collections objects.

PR Type

Enhancement, Tests


Description

  • Add deque support in comparator function

  • Import Optional in git_utils.py

  • Add test_collections for various deque scenarios


Diagram Walkthrough

flowchart LR
  A["orig,new objects"] --> B{"Sequence type?"}
  B -- "list/tuple/deque" --> C["Iterate and compare elements"]
  B -- "other types" --> D["Other comparison logic"]
  C --> E{"All elements equal?"}
  E -- "yes" --> F["return True"]
  E -- "no" --> G["return False"]
Loading

File Walkthrough

Relevant files
Enhancement
git_utils.py
Add Optional import                                                                           

codeflash/code_utils/git_utils.py

  • Added Optional import from typing
+1/-1     
comparator.py
Enable deque comparison in comparator                                       

codeflash/verification/comparator.py

  • Imported deque from collections
  • Extended sequence check to include deque
  • Recursively compare deque elements
+2/-1     
Formatting
beta.py
Minor formatting adjustment                                                           

codeflash/lsp/beta.py

  • Inserted blank line for code readability
+1/-0     
Tests
test_comparator.py
Add deque collection tests                                                             

tests/test_comparator.py

  • Imported deque in tests
  • Added test_collections to validate deque behaviors
  • Covered equal, unequal, empty, and maxlen scenarios
+27/-0   

@aseembits93 aseembits93 requested review from KRRT7 and misrasaurabh1 and removed request for KRRT7 September 3, 2025 00:21
@github-actions
Copy link

github-actions bot commented Sep 3, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Unused Import

Optional and TYPE_CHECKING are imported but not used in this module; consider removing unused imports to keep the code clean.

from typing import TYPE_CHECKING, Optional
Superset Behavior

The superset_obj flag is not applied to sequence types (list, tuple, deque), so a new sequence with extra elements will always fail comparison; clarify if superset logic should extend to sequences.

if isinstance(orig, (list, tuple, deque)):
    if len(orig) != len(new):
        return False
    return all(comparator(elem1, elem2, superset_obj) for elem1, elem2 in zip(orig, new))

@github-actions
Copy link

github-actions bot commented Sep 3, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Honor superset flag for sequences

Update sequence comparison to respect the superset_obj flag by allowing the new
sequence to be longer when it’s set. This ensures consistency with the behavior for
mappings.

codeflash/verification/comparator.py [74-77]

 if isinstance(orig, (list, tuple, deque)):
-    if len(orig) != len(new):
-        return False
+    if superset_obj:
+        if len(new) < len(orig):
+            return False
+    else:
+        if len(orig) != len(new):
+            return False
     return all(comparator(elem1, elem2, superset_obj) for elem1, elem2 in zip(orig, new))
Suggestion importance[1-10]: 9

__

Why: The update ensures that when superset_obj is True, sequences can have extra elements, fixing a functional gap.

High

@aseembits93 aseembits93 merged commit 8753e54 into main Sep 3, 2025
18 of 21 checks passed
@KRRT7 KRRT7 deleted the deque-comparator branch September 3, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants