Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(deps[colorama]): replace colorama with stdlib ANSI constants
why: colorama wraps fixed ANSI escape string constants the stdlib can
provide directly. Removing it shrinks the dependency tree.
what:
- Replace all colorama Fore/Style references in log.py with raw ANSI
  escapes via _ansi_colors from tmuxp._internal.colors
- Remove colorama and types-colorama from pyproject.toml
  • Loading branch information
tony committed Mar 8, 2026
commit 3d7b95138b3879d12912a8a56101f15b660c6839
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ include = [
]
dependencies = [
"libtmux~=0.55.0",
"colorama>=0.3.9",
"PyYAML>=6.0"
]

Expand Down Expand Up @@ -82,7 +81,6 @@ dev = [
# Lint
"ruff",
"mypy",
"types-colorama",
"types-docutils",
"types-Pygments",
"types-PyYAML",
Expand Down Expand Up @@ -118,7 +116,6 @@ coverage =[
lint = [
"ruff",
"mypy",
"types-colorama",
"types-docutils",
"types-Pygments",
"types-PyYAML",
Expand Down
67 changes: 35 additions & 32 deletions src/tmuxp/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
import time
import typing as t

from colorama import Fore, Style
from tmuxp._internal.colors import _ansi_colors, _ansi_reset_all

logger = logging.getLogger(__name__)

_ANSI_RESET = _ansi_reset_all # "\033[0m"
_ANSI_BRIGHT = "\033[1m"
_ANSI_FG_RESET = "\033[39m"

LEVEL_COLORS = {
"DEBUG": Fore.BLUE, # Blue
"INFO": Fore.GREEN, # Green
"WARNING": Fore.YELLOW,
"ERROR": Fore.RED,
"CRITICAL": Fore.RED,
"DEBUG": f"\033[{_ansi_colors['blue']}m",
"INFO": f"\033[{_ansi_colors['green']}m",
"WARNING": f"\033[{_ansi_colors['yellow']}m",
"ERROR": f"\033[{_ansi_colors['red']}m",
"CRITICAL": f"\033[{_ansi_colors['red']}m",
}


Expand Down Expand Up @@ -103,27 +107,27 @@ def template(
str
Template for logger message.
"""
reset = Style.RESET_ALL
reset = _ANSI_RESET
levelname = set_style(
"(%(levelname)s)",
stylized,
style_before=(LEVEL_COLORS.get(record.levelname, "") + Style.BRIGHT),
style_after=Style.RESET_ALL,
style_before=(LEVEL_COLORS.get(record.levelname, "") + _ANSI_BRIGHT),
style_after=_ANSI_RESET,
suffix=" ",
)
asctime = set_style(
"%(asctime)s",
stylized,
style_before=(Fore.BLACK + Style.DIM + Style.BRIGHT),
style_after=(Fore.RESET + Style.RESET_ALL),
style_before=(f"\033[{_ansi_colors['black']}m" + _ANSI_BRIGHT),
style_after=(_ANSI_FG_RESET + _ANSI_RESET),
prefix="[",
suffix="]",
)
name = set_style(
"%(name)s",
stylized,
style_before=(Fore.WHITE + Style.DIM + Style.BRIGHT),
style_after=(Fore.RESET + Style.RESET_ALL),
style_before=(f"\033[{_ansi_colors['white']}m" + _ANSI_BRIGHT),
style_after=(_ANSI_FG_RESET + _ANSI_RESET),
prefix=" ",
suffix=" ",
)
Expand Down Expand Up @@ -173,42 +177,41 @@ def debug_log_template(
str
Log template.
"""
reset = Style.RESET_ALL
reset = _ANSI_RESET
levelname = (
LEVEL_COLORS.get(record.levelname, "")
+ Style.BRIGHT
+ _ANSI_BRIGHT
+ "(%(levelname)1.1s)"
+ Style.RESET_ALL
+ _ANSI_RESET
+ " "
)
asctime = (
"["
+ Fore.BLACK
+ Style.DIM
+ Style.BRIGHT
+ f"\033[{_ansi_colors['black']}m"
+ _ANSI_BRIGHT
+ "%(asctime)s"
+ Fore.RESET
+ Style.RESET_ALL
+ _ANSI_FG_RESET
+ _ANSI_RESET
+ "]"
)
name = (
" "
+ Fore.WHITE
+ Style.DIM
+ Style.BRIGHT
+ f"\033[{_ansi_colors['white']}m"
+ _ANSI_BRIGHT
+ "%(name)s"
+ Fore.RESET
+ Style.RESET_ALL
+ _ANSI_FG_RESET
+ _ANSI_RESET
+ " "
)
module_funcName = Fore.GREEN + Style.BRIGHT + "%(module)s.%(funcName)s()"
module_funcName = (
f"\033[{_ansi_colors['green']}m" + _ANSI_BRIGHT + "%(module)s.%(funcName)s()"
)
lineno = (
Fore.BLACK
+ Style.DIM
+ Style.BRIGHT
f"\033[{_ansi_colors['black']}m"
+ _ANSI_BRIGHT
+ ":"
+ Style.RESET_ALL
+ Fore.CYAN
+ _ANSI_RESET
+ f"\033[{_ansi_colors['cyan']}m"
+ "%(lineno)d"
)

Expand Down
15 changes: 0 additions & 15 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.