refactor: Implement code review suggestions for emoji disable feature

- Move EMOJI_MAP to module level as DEFAULT_EMOJI_MAP for memory efficiency
- Add _parse_bool_env() helper function for cleaner boolean conversion
- Implement performance optimization with icon caching
- Improve error handling for unknown emojis with better fallback format
- Update tests to work with new module structure
- All functionality preserved and tests passing

Addresses feedback from PR review #3063

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-06-25 13:02:32 +00:00
parent 4e288e4cf7
commit a9823a4368
2 changed files with 50 additions and 33 deletions

View File

@@ -96,11 +96,11 @@ class TestConsoleFormatterEmojiDisable:
assert formatter._get_icon(emoji) == expected_text
def test_unknown_emoji_fallback(self):
"""Test that unknown emojis fall back to ASCII-only representation."""
"""Test that unknown emojis fall back to proper representation."""
with patch.dict(os.environ, {"CREWAI_DISABLE_EMOJIS": "true"}):
formatter = ConsoleFormatter(verbose=True)
result = formatter._get_icon("🦄")
assert result == ""
assert result == "[ICON:UNKNOWN]"
@patch.dict(os.environ, {"CREWAI_DISABLE_EMOJIS": "true"})
def test_crew_tree_creation_without_emojis(self):