Skip to content

Fix miscased Fore.Yellow in DataClassNode.print - #163

Merged
ESultanik merged 1 commit into
masterfrom
153-fore-yellow-typo
Sep 9, 2026
Merged

ESultanik merged 1 commit into
masterfrom
153-fore-yellow-typo

Conversation

@ESultanik

Copy link
Copy Markdown
Collaborator

Closes #153

graphtage/dataclasses.py:150 spelled the colorama attribute as Fore.Yellow. The real attribute is Fore.YELLOW, which is what every other call site in the package uses, so DataClassNode.print() raised AttributeError: 'AnsiFore' object has no attribute 'Yellow' every time it ran.

DataClassNode.print() is the fallback rendering path that TreeNode.print() takes when no formatter resolves the node type (graphtage/tree.py:72-76), 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 can skip the context, so it also crashed with ansi_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.py call DataClassNode.print() directly, which is what reaches the buggy path:

  • test_print_renders_slots asserts the uncolored rendering equals Foo(name="x", count=3).
  • test_print_colors_the_class_name_yellow asserts Fore.YELLOW precedes the class name under ansi_color=True.

Both tests were confirmed to catch the bug:

  • Against the unfixed code, both fail with AttributeError: 'AnsiFore' object has no attribute 'Yellow'.
  • With the color context removed entirely rather than corrected, test_print_colors_the_class_name_yellow fails 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 bindist
  • pytest (142 passed)
  • make -C docs html SPHINXOPTS="-W --keep-going"

uv lock --check reports the lockfile needs updating, but it does so identically on a pristine checkout of master in this environment (a global exclude-newer setting forces re-resolution). Neither pyproject.toml nor uv.lock is touched by this change.

I also grepped the package for other miscased colorama attributes across Fore., Back., and Style.. This was the only one.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GypKU5KdLfs2Cf8kS2TzJa

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
@ESultanik
ESultanik merged commit 13a2893 into master Sep 9, 2026
11 checks passed
@ESultanik
ESultanik deleted the 153-fore-yellow-typo branch September 9, 2026 14:28
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.

DataClassNode.print() raises AttributeError on Fore.Yellow

1 participant