Fix miscased Fore.Yellow in DataClassNode.print - #163
Merged
Merged
Conversation
The colorama attribute is spelled Fore.YELLOW, so DataClassNode.print raised AttributeError: 'AnsiFore' object has no attribute 'Yellow' every time it ran. This is the fallback rendering path that TreeNode.print takes when no formatter resolves the node type, so any DataClassNode subclass without a dedicated formatter crashed instead of printing. The failure was not limited to color output. The attribute is read to build the argument to printer.color(), before the only_ansi wrapper on that method has a chance to skip the context, so it also crashed with ansi_color=False. Add regression tests covering both the uncolored rendering and the yellow class name, so that dropping the color rather than fixing its spelling is also caught. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa
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.
Closes #153
graphtage/dataclasses.py:150spelled the colorama attribute asFore.Yellow. The real attribute isFore.YELLOW, which is what every other call site in the package uses, soDataClassNode.print()raisedAttributeError: 'AnsiFore' object has no attribute 'Yellow'every time it ran.DataClassNode.print()is the fallback rendering path thatTreeNode.print()takes when no formatter resolves the node type (graphtage/tree.py:72-76), so anyDataClassNodesubclass without a dedicated formatter crashed instead of printing. The failure was not limited to color output: the attribute is read to build the argument toprinter.color(), before theonly_ansiwrapper on that method can skip the context, so it also crashed withansi_color=False.The fix is one character. The rest of
DataClassNode.print()renders correctly once it is reachable —Foo(name="x", count=3), with the class name yellow, the slot names red, and the=bright.Validation
Two regression tests in
test/test_dataclasses.pycallDataClassNode.print()directly, which is what reaches the buggy path:test_print_renders_slotsasserts the uncolored rendering equalsFoo(name="x", count=3).test_print_colors_the_class_name_yellowassertsFore.YELLOWprecedes the class name underansi_color=True.Both tests were confirmed to catch the bug:
AttributeError: 'AnsiFore' object has no attribute 'Yellow'.test_print_colors_the_class_name_yellowfails on the missing escape, so a silently dropped color is caught as well as a crash.Local CI, all passing:
ruff check graphtage test docs bindistpytest(142 passed)make -C docs html SPHINXOPTS="-W --keep-going"uv lock --checkreports the lockfile needs updating, but it does so identically on a pristine checkout ofmasterin this environment (a globalexclude-newersetting forces re-resolution). Neitherpyproject.tomlnoruv.lockis touched by this change.I also grepped the package for other miscased colorama attributes across
Fore.,Back., andStyle.. This was the only one.🤖 Generated with Claude Code
https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa