Repository navigation
Version 8.0.0 - #346
Merged
Merged
Version 8.0.0#346
Conversation
…x follows - Add test case for issue #305 documenting the bug - Fix __convert_and_store to merge dict values into existing Box when: - box_dots is enabled - key already exists as a Box (created from dotted keys) - during initialization (__created is False) - This ensures dotted keys like 'a.b: c' are preserved when followed by a non-dotted key like 'a: {d: e}' in YAML files
Box.__init__ derives box_class from self.__class__, but Box.__new__ hardcoded the base Box. Unpickling calls __new__ + __setstate__ (not __init__), so a subclass instance ended up with box_class=Box, and nested boxes created on access after unpickling became base Box instead of the subclass. Use cls in __new__ to match __init__.
BoxList.__setitem__ unconditionally replaced the element at the target index with a fresh empty container before recursing, so a second dotted write into an existing element (a[0].y after a[0].x) discarded the keys already stored there. Only replace the element when it is not already the right container type, matching the guard in Box.__setitem__.
…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.
frozen_box stores lists as tuples of Boxes for immutability, but Box.to_dict() only recursed into Box and BoxList values -- not tuples -- so the nested Boxes were left unconverted. to_yaml() then failed with RepresenterError since ruamel can't represent a Box. Recurse into tuples in to_dict(), converting nested Box/BoxList members back to native types while preserving the tuple. Fixes #272.
`BoxList.__deepcopy__` built the copy as `self.__class__()` with no `box_options`, so `copy.deepcopy()` silently dropped every option (`frozen_box`, `box_dots`, `default_box`, `box_intact_types`, …). A frozen BoxList became mutable (and unhashable) after a deepcopy. `BoxList.__copy__` and `Box.__deepcopy__` both preserve options; `BoxList.__deepcopy__` was the outlier. Mirror `Box.__deepcopy__`: build unfrozen, register in memo before recursing (keeps cycle-safety), populate, then re-freeze via `__init__`.
Pickle assigns items before __setstate__, so nested Box objects were recreated with default options and dotted lookups failed after load.
merge_update can already combine lists with extend and unique, but there was no way to merge lists of dictionaries the way nested dicts merge. Add a "merge" option that walks both lists by index, recursing into dicts at the same position so their keys combine and appending any extra incoming items. Closes #263.
default_box_create_on_get=False still needs b.foo.bar = 1 to persist. Lookups stay ephemeral. Writes attach the pending chain.
Guard unmatched index expressions in dotted reads, writes and deletes. Add regressions for nested paths, default/frozen modes and YAML loading. Independent review: passed (security and logic). AI-assisted contribution prepared with Hermes DEV.
setup.py is reduced to the optional Cython ext_modules; Cython is deliberately not a build requirement so sdist installs stay pure Python. Dropped the stray py_modules=['box'] and platforms='any' (meaningless for compiled wheels). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ff config - [dependency-groups] test/dev in pyproject.toml (toon_format as a direct git reference), uv.lock added - [tool.ruff] (line length 120, py311, black compatible format; E/F/W/I lint), pre-commit uses ruff-pre-commit - coverage and cibuildwheel configuration moved into pyproject.toml - removed .black.toml, .coveragerc and requirements*.txt, dropped the no-op cythonize pre-commit hook Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…f and pyproject builds - tests.yml/pythonpublish.yml use astral-sh/setup-uv, uv sync/build and uvx twine/cibuildwheel (same matrix, targets and secrets) - add a ruff lint/format-check job - document building the Cython version with --no-build-isolation now that metadata is in pyproject.toml Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Mechanical changes from ruff format and ruff check --fix (import sorting, unused imports, quote style), plus noqa for the few intentional findings (== True assertions, one long test string). box/__init__.py is excluded from F401/I001 via per-file-ignores because its import order matters. config_box.pyi uses builtins.bool instead of a type-ignore that the formatter would have moved. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…_attrs Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Use toon-format 1.2.0 from PyPI instead of an unpinned git URL (now hash-locked in uv.lock, and pinned for cibuildwheel/pip which read pyproject) - Split manylinux publish into a build job (runs tests, no secrets) and an upload-only job, so third party test deps never run alongside PyPI creds - Quote Cython>=3.3.0 in cibuildwheel before-build (was a shell redirect) - Pin uvx tools (ruff 0.17.3 to match lock/pre-commit, cibuildwheel 4.3.5, twine 6.2.0) so CI does not drift - Point uv at the setup-python interpreter (UV_PYTHON) in matrix jobs so each cell, including pypy, tests the interpreter it claims to Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g UV_PYTHON Exporting UV_PYTHON made uv build / uv pip target the bare interpreter rather than the project .venv, so --no-build-isolation builds could not find setuptools. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vinson0522) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed booleans and keys The submitted conversion turned anchored booleans (ruamel ScalarBoolean, not an int subclass in the bool sense) into int 1, and converted ruamel string types to str, which dropped literal block style and preserved quotes on to_yaml. Strings are now left untouched, ScalarBoolean maps to bool, and mapping keys are converted too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…el env) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PR as submitted crashed on non-string keys, silently merged keys that differ only by case into the first spelling, made update and merge_update disagree, and scanned every key on each miss. * Only str keys are matched ignoring case, other keys match exactly * A ConfigBox never holds two keys differing only by case: the latest write wins, keeping its value and its spelling (construction, [] and attribute assignment, update, merge_update and |) * Lookups, in, del, pop, get and box_dots paths (first segment, nested ConfigBoxes match the rest) all resolve case-insensitively * A lower-case index in the box config makes misses O(1). It is rebuilt when the dict size changes behind ConfigBox's back * A stale default_box ephemeral child is not attached when the key was since assigned under a different spelling * Frozen ConfigBoxes still refuse every write Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… key order, camel keep keys, int keys in dotted paths * #262 default_box_create_on_get now defaults to False, so attribute probing (IPython, Spyder, hasattr) never adds keys. pop() of a missing key and hasattr + delattr (argparse namespaces) keep working with it. * #296 / #223 / #210 _box_defaults class attribute: subclasses change option defaults without overriding __init__. Options are now read from kwargs in one place (_build_box_config), so an explicit option still wins. DDBox uses it. * #104 to_yaml keeps insertion order for PyYAML and ruamel safe / unsafe too, sort_keys=True sorts. * #279 camel_killer_box_keep_keys keeps CamelCase keys and adds snake_case attribute aliases through conversion_box. * #123 box_dots path segments made of digits also match int keys. Only for path segments, a str key of the same value wins, plain keys are not mapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- All build jobs (generic sdist/wheel, macOS/Windows Cython wheels, manylinux cibuildwheel) run without secrets and upload artifacts - A single publish job, gated on every build succeeding, downloads all distributions and uploads via PyPI Trusted Publishing (OIDC) in the "pypi" environment; its only permission is id-token: write - No PYPI_USERNAME / PYPI_PASSWORD secrets are used anymore - Pin every action in both workflows to a full commit SHA - Default token permissions to none, checkout without persisted credentials, add job timeouts, twine check every build Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Tests for the remaining reachable paths (error branches, optional YAML / TOML / TOON backends, ConfigBox index upkeep, default_box_attr call signatures, IPython probes, reflected operators). Code that could not run was removed instead: * _parse_box_dots error handlers at call sites that already guarantee a "." or "[" in the key, and its unreachable `setting` split * the _dunder_ check in __get_default (__getattr__ refuses those names first) and the __getstate__ AttributeError case (Box defines __getstate__) * tomli / toml read fallbacks (tomllib is always present on Python 3.11+) and try/except blocks around TOML writes that only caught decode errors * box_from_string's BoxList fallback for TOML (a TOML document is always a table) * DDBox.__repr__, identical to the inherited SBox one Import time environment fallbacks and the Python 3.11 slice branch are marked `pragma: no cover`. A new pure Python CI job fails below 100%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* `in` / get() for box_dots paths through lists ('a[0].x'), and no longer
treating substrings of string values as keys
* IndexError on a box_dots key ending with "." with default_box
* _get_property_func assumed every class attribute was a property; the
msgpack / toon converters are now protected keys like the others
* BoxList.__deepcopy__ of a frozen list unfroze the copied Boxes
* BoxList pickling appended items before restoring box_options, so items were
rebuilt with default options (and unfrozen). __reduce_ex__ now keeps the
items in the state, Box 7 pickles still load through __setstate__
A sixth finding, BoxList += not converting items, stays a strict xfail: PR #347
fixes it. The setdefault box_dots fallback is gone, `in` covers it now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pyproject dependency group minimums raised to the current releases, and the pytest-cov<6 cap lifted (pytest-cov 7.1.0); uv.lock upgraded with uv 0.13.7 * Cython 3.3.1 for cibuildwheel and the publish workflow, twine 7.0.0 * pre-commit: pre-commit-hooks v6.0.0 (drops the removed fix-encoding-pragma hook), mirrors-mypy v2.4.1 with current type dependencies * Fix the 4 errors the per-file pre-commit mypy run reports (StringIO / file variable type, list operator signatures, Callable in a type comment) ruff 0.17.3 and cibuildwheel 4.3.5 were already the latest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lt_box_attr, ConfigBox "off" * __radd__ / __ror__ build the result from a plain dict with the Box's class and options (unfrozen, top level namespace), like __sub__ already did * default_box_attr: list maps to BoxList like [] does, other classes and functions are called like defaultdict factories. key / box_instance are passed by keyword (positional only parameters positionally), any other required parameter is an error * ConfigBox.bool: "off" is false, as in configparser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comments live outside the data, in a per container store
({key: {"before": [lines], "eol": text}} plus document start / end), so
to_dict, to_json, equality and hashing never see them.
* from_yaml with ruamel's round trip loader extracts them (box.comments
re-assigns ruamel's "comment above a key" tokens, which it parses onto the
previous key), to_yaml rebuilds CommentedMap / CommentedSeq objects and
writes them back. Without comments, or with PyYAML / the safe dumper, the
output is exactly as before.
* get_comment / set_comment / del_comment on Box and BoxList, positions
"eol" / "before", key None for the document ("start" / "end"), box_dots
paths, negative list indexes, frozen boxes refuse changes.
* Kept in sync: deletes, pop, popitem, clear drop them; ConfigBox latest
write wins keeps the comment on the new spelling; camel_killer keys;
BoxList insert / pop / remove / del / reverse / sort move them with their
items (slice writes drop them); copy, deepcopy, pickle and Box(other_box)
carry them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… characters
A comment containing \r, \x85, \u2028 or \u2029 was written with that
character inside a "#" line, and YAML parsers read the rest of the line as
document content, so set_comment("a", "x\rinjected: 1") added a key on reload.
All YAML line breaks now split comment lines (end of line comments reject them)
and other control characters are refused. Found by the automated security review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion (@theman6660) Moved the AUTHORS entry to the end of the list, and removed the strict xfail on the edge case test this fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Version 8.0.0
Everything below is on
develop. The full list with credits is inCHANGES.rst, and the wiki's "Major Version Breaking Changes" page has before / after examples.Breaking changes
default_box_create_on_getdefaults toFalse(Unexpected attributes "size" and "compute" #262): looking up a missing key no longer stores it, so IPython / Spyder attribute probing doesn't add keys. Assigning through missing keys still creates them (box.a.b = 1, default_box_create_on_get=False should still create keys on assigment #274). Changing a default value in place (box.tags.append(1)) is no longer kept; passdefault_box_create_on_get=Truefor the old behavior.[],in,del,get,update,merge_updateand box_dots paths, not only attributes. A ConfigBox never holds keys that differ only by case: the latest write wins, keeping its value and spelling.to_yamlkeeps insertion order with PyYAML and the ruamel safe / unsafe dumpers too (to_yaml() does not honor ordered_box #104);sort_keys=Truesorts.to_yamlwrites back the commentsfrom_yamlread.get_comment,set_commentanddel_commentare new protected names.Box.popitem()is LIFO likedict.popitem().merge_updateraisesBoxValueErrorfor an unknownbox_merge_listsvalue.copy(),copy.copy()andcopy.deepcopy()keep the subclass.__new__/__init__(calls work the same, the type stubs still list them). DDBox options can be overridden.--no-build-isolation; sdist installs need setuptools>=77.New features
get_comment/set_comment/del_commenton any Box or BoxList (positionseol/before, documentstart/end, box_dots paths). Comments stay out of the data and follow their keys and items through edits, copies and pickles._box_defaults: subclasses set option defaults without overriding__init__(also answers cannot froze a subclass #223 and Default Box fails to handle singleton instances of itself #210)._box_internal_attrs: instance attributes kept out of the data.camel_killer_box_keep_keys: snake_case attribute names without renaming the original CamelCase keys.merge_updateinto BoxLists #263box_merge_lists="merge": merge lists of dicts element by element.box["servers.2"]finds{"servers": {2: ...}}.default_box_attraccepts factories such aslist,intorset, likedefaultdict.Fixes
box_from_filereturnsruamel.yaml.scalarfloat.ScalarFloatinstead offloatfor floating-point values #264 ruamel scalar types (ScalarFloat / ScalarInt / ScalarBoolean) are converted to plain Python values on load, leaving strings and their formatting alone.Boxdoes not unpickle correctly #308, Frozen BoxList instances cannot be pickled #344 pickling: nested box_dots, subclasses of nested boxes, frozen BoxLists. BoxList pickles also keep the options of the Boxes inside them now, and Box 7 pickles still load.box_dots=True#265, fozen_box with lists cannot converted to YAML #272, [Bug] Camel killer box and box dots gives unexpected behaviour #300, Dotted keys read from YAML are lost with box_dots / default_box #305 YAML / box_dots / camel killer bugs."a[0].x" in boxandbox.get("a[0].x")work for paths through lists, andinno longer matches substrings of string values.dict | Boxanddict + Boxkeep the Box's options.clear,+=and*=, and their items stay frozen afterdeepcopy/ pickle.+=(Convert nested containers during BoxList in-place addition #347), item and slice assignment.ConfigBox.bool("off")is False, matching configparser.pop()/hasattr+delattrof missing keys on default boxes, so argparse namespaces work.to_msgpack/to_toonand other non-property class attributes no longer raises AttributeError.update()with positional and keyword arguments,ensure_ascii, and more from community PRs.Security, tooling and CI
pyproject.toml(PEP 621) withsetup.pyonly for the optional Cython build; uv withuv.lock; ruff instead of black.inand protected-name bugs above. Code that could never run was removed instead of being tested around.Merged pull requests
#306, #309, #310, #314, #315, #319, #321, #322, #323, #324, #326, #328, #330, #331, #332, #335, #336, #337, #338, #339, #340, #341, #342, #343, #345, #347, #348
Closes #104
Closes #123
Closes #184
Closes #210
Closes #223
Closes #260
Closes #262
Closes #263
Closes #264
Closes #265
Closes #269
Closes #272
Closes #274
Closes #279
Closes #296
Closes #300
Closes #305
Closes #308
Closes #344
🤖 Generated with Claude Code