feat: RuleDictConsistency忽略顺序#391
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the RuleDictConsistency class by introducing a normalization method that supports order-insensitive comparisons for nested data structures such as dictionaries, lists, and sets. Additionally, the documentation is updated to simplify LLM configuration by replacing specific parameter lists with a general pass-through policy. A review comment suggests using repr() instead of str() for sorting dictionary keys to improve robustness when handling mixed-type keys and to maintain consistency with other sorting logic in the class.
| if isinstance(value, dict): | ||
| return { | ||
| key: cls._normalize_value(value[key], ignore_order) | ||
| for key in sorted(value.keys(), key=lambda x: str(x)) |
There was a problem hiding this comment.
Using repr(x) as the sorting key is more robust than str(x) when dealing with mixed-type keys (e.g., it correctly distinguishes between the integer 1 and the string '1'). This also ensures consistency with the sorting logic used for lists and sets on lines 2708 and 2713.
| for key in sorted(value.keys(), key=lambda x: str(x)) | |
| for key in sorted(value.keys(), key=lambda x: repr(x)) |
No description provided.