removesuffix helper returns an empty string for an empty suffix

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

まだ誰も着手していません。

評価

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

調査の方向性

src/browserbase/_utils/_utils.py:368-375 から始め、関連する prefix helper と併せて removesuffix の実装を確認します。既存のテストスイートを実行し、その後、空文字列の prefix と suffix のケースをカバーするテストを追加します。removesuffix("abc", "") が "abc" を返し、標準ライブラリの動作と一致すれば完了です。

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

説明

Description

The internal removesuffix helper claims to backport str.removesuffix, but it returns an empty string when the requested suffix is empty.

Code reference

src/browserbase/_utils/_utils.py:368-375

The implementation executes string[:-len(suffix)]; for an empty suffix this becomes string[:-0], which is string[:0].

Reproduction

from browserbase._utils._utils import removesuffix

print(repr(removesuffix("abc", "")))
print(repr("abc".removesuffix("")))

Actual:

''
'abc'

Expected behavior

To match the documented stdlib behavior, an empty suffix should leave the original string unchanged.

Why it matters

This shared helper silently corrupts input for a valid edge case and has no direct test coverage. Even though current in-repo call sites are limited, it is exported through browserbase._utils and may be reused by generated or manual code later. The fix is small (if suffix and string.endswith(suffix): ...) and should include empty-string tests for both prefix/suffix helpers.

主要言語
Python
スター
93
フォーク
16
平均マージ
11分
マージ済み PR(30日)
3

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

browserbase/sdk-python のほかの issue

browserbase/sdk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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