Skip to content

Version 8.0.0 - #346

Merged
cdgriffith merged 87 commits into
masterfrom
develop
Nov 4, 2026
Merged

cdgriffith merged 87 commits into
masterfrom
develop

Conversation

@cdgriffith

@cdgriffith cdgriffith commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Version 8.0.0

Everything below is on develop. The full list with credits is in CHANGES.rst, and the wiki's "Major Version Breaking Changes" page has before / after examples.

Breaking changes

New features

Fixes

Security, tooling and CI

  • Comment text can never escape into YAML content: every YAML line break splits comment lines, and control characters are rejected.
  • PyPI publishing uses Trusted Publishing, and actions are pinned to SHAs (Publish to PyPI with Trusted Publishing; pin actions to SHAs #348). The manylinux build runs in a job without PyPI access.
  • pyproject.toml (PEP 621) with setup.py only for the optional Cython build; uv with uv.lock; ruff instead of black.
  • Development dependencies on their latest versions (pytest 9, pytest-cov 7, mypy 2, twine 7, Cython 3.3.1, pre-commit-hooks 6).
  • 100% line and branch coverage, enforced by a CI job. 693 tests, up from 301, including 80 edge case tests that found the BoxList pickle / deepcopy, in and 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

cdgriffith and others added 30 commits February 21, 2026 10:12
…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.
cdgriffith and others added 8 commits November 3, 2026 20:57
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>
@cdgriffith cdgriffith changed the title Version 7.5.0 Version 8.0.0 Nov 4, 2026
cdgriffith and others added 9 commits November 3, 2026 21:12
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>
cdgriffith and others added 8 commits November 4, 2026 08:14
- 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>
@cdgriffith
cdgriffith marked this pull request as ready for review November 4, 2026 14:28
@cdgriffith
cdgriffith merged commit 25caeb5 into master Nov 4, 2026
36 checks passed
@cdgriffith
cdgriffith deleted the develop branch November 4, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment