EllipsisMiddleTruncate exceeds requested width when only the ellipsis fits

オープン 初心者向け
#722 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

@hugosmoreira がすでに取り組んでいます。

2026年10月26日 から。

  • #724 @hugosmoreira による — オープン
  • #726 @MateehUllah による — オープン

評価

難易度
1/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
cli

調査の方向性

fire/formatting.pyから始めてEllipsisMiddleTruncateを調べ、長さがゼロの後半部分と、切り詰めが発生しない境界に注目してください。issueの2つの例を再現し、出力が指定された幅以内に収まり、ちょうど収まる文字列が保持されることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

EllipsisMiddleTruncate returns more characters than the requested width when available_space is 3. It also modifies strings that already fit exactly within the specified width.

Steps to reproduce
from fire import formatting

print(formatting.EllipsisMiddleTruncate('abcdefghij', 3, 80))
# Actual: '...abcdefghij'
# Expected: '...'

print(formatting.EllipsisMiddleTruncate('abcd', 4, 80))
# Actual: '...d'
# Expected: 'abcd'
Cause

The expression text[-second_half_len:] returns the entire string when second_half_len is zero. The no-truncation check also uses < instead of <=.

Expected behavior

Output should respect the available width, and strings that already fit should remain unchanged.

Verification

Reproduced using the implementation from fire/formatting.py.

主要言語
Python
スター
28.2k
フォーク
1.5k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google/python-fire のほかの issue

google/python-fire の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。