refactor: use shared PRINTER singleton#5329
Merged
Merged
Conversation
iris-clawd
approved these changes
Apr 7, 2026
iris-clawd
left a comment
Contributor
There was a problem hiding this comment.
Review: PRINTER singleton
Clean mechanical refactor. 22 files, net -37 lines, all Printer() / _printer / PrivateAttr(default_factory=Printer) replaced with PRINTER singleton.
✅ Approve
Printeris stateless (just wrapsprint()with ANSI colors), so a singleton is the correct pattern — no shared mutable state concerns.- Removes unnecessary
PrivateAttr,ClassVar, and module-level_printer = Printer()instances across the codebase. - Import path is consistent:
from crewai.utilities.printer import PRINTEReverywhere. Printerclass is still exported for the few places that pass it as a parameter (e.g.,handle_unknown_error(printer, ...)) — good, no breaking changes to function signatures.
No concerns. Ship it. ✅ 💬 177
iris-clawd
approved these changes
Apr 7, 2026
iris-clawd
left a comment
Contributor
There was a problem hiding this comment.
Re-approving after new commits. ✅
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.
Summary
Printer()instantiations and_printerattributes/variables with the sharedPRINTERsingleton fromutilities/printer.pyPrivateAttrdeclarations, module-level variables, andClassVarforPrinteracross 22 filesTest plan
Note
Low Risk
Broad but mechanical refactor across executors/hooks/CLI to centralize printing; low functional risk, with main concern being any code that relied on per-instance printer state or test patching paths.
Overview
Standardizes console output by introducing a module-level
PRINTERsingleton inutilities/printer.pyand migrating call sites to use it instead of constructingPrinter()instances or storing_printer/_printerglobals.This removes multiple
Printerattributes/PrivateAttr/ClassVarfields and updates error/verbose logging paths in executors, hooks, CLI commands, flow persistence/utils, and tool/LLM handling to passPRINTERthrough to helper functions. Tests were adjusted to patch/mockPRINTERrather than mutating instance printers.Reviewed by Cursor Bugbot for commit 22f02e7. Bugbot is set up for automated code reviews on this repo. Configure here.