You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Collections: Preserve container types when normalizing - #5862
Since #5859, keys are also normalized with ignore_case=VALUES and values with ignore_case=KEYS. _try_to_preserve_type() can't rebuild namedtuples or ranges with cls(list), so they became lists, which made such dict keys unhashable and made such values compare equal to lists. This leaves ranges alone (they only contain integers, so there's nothing to normalize) and rebuilds namedtuples with _make; lists and other containers are handled exactly as before, and #5858's tests still pass.
Side effects, also in BuiltIn keywords using ignore_case, strip_spaces or collapse_spaces: ranges and namedtuples no longer compare equal to lists, which matches comparing without normalization and how plain tuples already behave. Ranges are also no longer sorted with ignore_order (ignore_value_order in Collections), so range(2) and range(1, -1, -1) are now reported as different.
Containers that normalization does not change are now returned as-is
and namedtuples are recreated using `_make`. Earlier they could be
converted to lists, which made namedtuple and range keys unhashable
with `ignore_case=VALUES` and made such values equal to lists with
`ignore_case=KEYS`.
Fixesrobotframework#5861.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This PR addresses container-type regressions introduced by recursive case normalization in Collections. It preserves unchanged hashable sequences and rebuilds namedtuples without converting them to lists.
Changes:
Preserve unchanged hashable sequences and reconstruct namedtuples with _make.
Add regression cases for hashable dictionary keys and range-versus-list value comparisons.
Register the new cases in the acceptance-test verification suite.
…e_order
Unchanged containers are now detected by item identity only. Equality
can hide normalization changes, for example `Counter({'A': 0})` equals
`Counter({'a': 0})`, which caused case differences inside tuples to be
reported. With `ignore_order`, values are always sorted and rebuilt
like earlier, so equivalent ranges in a different order compare equal.
Related to robotframework#5861.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Sequence normalization can still convert ranges into lists and reconstruct namedtuples when ignoring order, causing unhashable dictionary keys and comparison regressions.
Skip namedtuple reconstruction when ignoring order
src/robot/libraries/normalizer.py:118
The new _make path also runs when ignore_order is enabled, changing the existing sorted-list fallback for namedtuples. With Pair = namedtuple('Pair', 'x y'), dictionaries_should_be_equal({'item': Pair(2, 1)}, {'item': [1, 2]}, ignore_value_order=True) previously passed but now compares Pair(1, 2) against [1, 2] and fails. Skip namedtuple reconstruction when ignoring order to retain the sorting behavior promised in the PR description, and add this mixed-container regression case.
Ranges only contain integers that normalization cannot change, so they
are now returned as-is. This keeps them hashable regardless of the size
of the integers. The earlier identity based check failed with ranges
like `range(1000, 1002)` because iterating them creates new integer
objects. That check is not needed anymore and has been removed.
As a small functional change, ranges are not sorted with `ignore_order`
anymore.
Related to robotframework#5861.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
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.
Since #5859, keys are also normalized with
ignore_case=VALUESand values withignore_case=KEYS._try_to_preserve_type()can't rebuild namedtuples or ranges withcls(list), so they became lists, which made such dict keys unhashable and made such values compare equal to lists. This leaves ranges alone (they only contain integers, so there's nothing to normalize) and rebuilds namedtuples with_make; lists and other containers are handled exactly as before, and #5858's tests still pass.Side effects, also in BuiltIn keywords using
ignore_case,strip_spacesorcollapse_spaces: ranges and namedtuples no longer compare equal to lists, which matches comparing without normalization and how plain tuples already behave. Ranges are also no longer sorted withignore_order(ignore_value_orderin Collections), sorange(2)andrange(1, -1, -1)are now reported as different.Fixes #5861.