fix: case-insensitive ConfigBox key lookup for __getitem__, __contains__, __delitem__, __setitem__#314
Open
gaoflow wants to merge 1 commit into
Open
Conversation
…s__, __delitem__, __setitem__ ConfigBox docstring advertises "loosey goosey" case-insensitive access but __getitem__ (dict-style), __contains__, __delitem__ and __setitem__ had no case-insensitive support. __getattr__ only retried with lowered input, missing MixedCase→lowercase resolution. Add _case_insensitive_key() helper and override the four dunder methods to resolve keys case-insensitively. __getattr__ now uses the same key-scan fallback instead of the broken .lower() retry.
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.
ConfigBox advertises "loosey goosey" case-insensitive key access in its docstring,
but:
__getitem__(dict-stylecb['host']) had zero case-insensitive support — only exact match__contains__('host' in cb) was not overridden —Falsefor differently-cased keys__delitem__and__setitem__likewise had no case-insensitive support__getattr__only retried with.lower(), missing MixedCase→lowercase resolutionFix: Added
_case_insensitive_key()static helper that scans actual keyscase-insensitively, then overrode the five dunder methods to use it. Each
method tries exact match first (zero overhead for exact-case), then falls back
to case-insensitive scan.
Reproduction:
154/154 tests pass (5 toon-related failures pre-existing, missing toon_format).
This pull request was prepared with the assistance of AI, under my
direction and review.