Skip to content

Match integer globs against numeric string dictionary keys - #213

Open
rupayon123 wants to merge 1 commit into
dpath-maintainers:masterfrom
rupayon123:bugfix/212_integer_globs_string_keys
Open

rupayon123 wants to merge 1 commit into
dpath-maintainers:masterfrom
rupayon123:bugfix/212_integer_globs_string_keys

Conversation

@rupayon123

Copy link
Copy Markdown

An integer glob fails to match a numeric string dictionary key, even though segments.match documents normalizing integers on both sides. For example, dpath.get({'0': 'value'}, [0]) raises KeyError, while the reverse integer-key/string-glob lookup succeeds.

Normalize the glob with the existing int_str helper before fnmatchcase. The numeric-index fast path stays unchanged. Added a Hypothesis regression for both mixed-type directions and nonmatches, plus public get, values, search, set and delete coverage that checks an unrelated key survives mutations.

Both new tests fail before the change and pass after. tox -e py312 passes all 81 tests, including package build/install and existing negative-list-index coverage. Repository-wide Flake8 and diff checks also pass. Local validation used CPython 3.12.15 on macOS arm64; the other supported Python/OS combinations were not tested locally.

Fixes #212.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer globs do not match numeric string dictionary keys

1 participant