cfonts --gradient producing error with more than three colors
まだ誰も着手していません。
評価
調査の方向性
Reproduce the reported command cfonts "$(hostname)" --font "block" --gradient red,"#f80",green,blue --transition-gradient, then read cfonts/colors.py around get_gradient and cfonts/core.py around paint_gradient. Done means four or more gradient colors no longer trigger the reported AssertionError while the existing three-color behavior remains working.
索引モデルが issue の本文から書いたものです。
説明
Hi, I have an interesting environment in which to debug because I'm sharing $HOME folders between two systems, one using Fedora 41 with the original cfonts program, and one running python-cfonts on Debian 13 (testing/trixie) installed with pipx.
Each system that has a clone of $HOME or $ZSH folder runs a pretty_hostname function to announce where I am.
TL;DR - python-cfonts --gradient [colors] appears to error when given more than 3 colors. When I reduce the number of colors to 3, gradient appears as normal
environment information for Debian machine:
❯ which python3 && python3 --version
/usr/bin/python3
Python 3.13.2
❯ which pipx && pipx --version
/usr/bin/pipx
1.7.1
❯ uname -rv
6.12.12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.12-1 (2025-02-02)
Login banner argument:
cfonts "$(hostname)" --font "block" --gradient red,"#f80",green,blue --transition-gradient
The gradient colors are actually from an example pulled from the Fedora cfonts package documentation /usr/share/doc/cfonts/README.md line 356
355 │ ```sh
356 │ $ cfonts "text" --gradient red,"#f80",green,blue --transition-gradient
357 │ ```
Error output:
Traceback (most recent call last):
File "/home/avery/.local/bin/cfonts", line 8, in <module>
sys.exit(main())
~~~~^^
File "/home/avery/.local/share/pipx/venvs/python-cfonts/lib/python3.13/site-packages/cfonts/cli.py", line 169, in main
say(args.text, **options)
~~~^^^^^^^^^^^^^^^^^^^^^^
File "/home/avery/.local/share/pipx/venvs/python-cfonts/lib/python3.13/site-packages/cfonts/core.py", line 373, in say
write = render(text, **options)
File "/home/avery/.local/share/pipx/venvs/python-cfonts/lib/python3.13/site-packages/cfonts/core.py", line 336, in render
output = paint_gradient(
output,
...<5 lines>...
transition,
)
File "/home/avery/.local/share/pipx/venvs/python-cfonts/lib/python3.13/site-packages/cfonts/core.py", line 221, in paint_gradient
styles = pen.get_gradient(gradient, max_index - min_index + 1, transition)
File "/home/avery/.local/share/pipx/venvs/python-cfonts/lib/python3.13/site-packages/cfonts/colors.py", line 179, in get_gradient
assert sum(color_steps) == steps - 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
I see this assert sum(color_steps) == steps - 1 statement at cfonts/colors.py line 169.
I am figuring something's up with my syntax, even though it's pulled straight from the original cfonts README.md. In an attempt to diagnose my syntax, I've tried using the following alterations:
- wrapping only
#f80with double quotes (default) - wrapping only
#f80with single quotes - making
#f80#F80 - wrapping all colors with single and double quotes
- wrapping only the
#f80with single and double quotes - wrapping each color in single quotes and all colors with double quotes
Let me know if you have any ideas, I can try poking around at stuff.
PS: removing one of the colors of the gradient as workaround (no rush).
- 主要言語
- Python
- スター
- 192
- フォーク
- 12
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
frostming/python-cfonts のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 20/100
frostming/python-cfonts#47 ·
frostming/python-cfonts の issue をすべて見る
似ている issue
-
Unknown stop ID in slow zone data crashes post formatting and skips the rest of that day's postsオープンbackend bug tm-new-volunteer
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
transitmatters/mbta-slow-zone-bot#81 · コメント 1 件 ·
-
area:schema documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
risk:high type:ci
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
spacetelescope/rdmt-spire#49 ·
メンテナーはふだん 1 日以内に返信