Skip to content

fix: handle empty suffix in removesuffix - #190

Open
abhinavkr26104 wants to merge 1 commit into
browserbase:mainfrom
abhinavkr26104:fix/issue-182-removesuffix-empty
Open

fix: handle empty suffix in removesuffix#190
abhinavkr26104 wants to merge 1 commit into
browserbase:mainfrom
abhinavkr26104:fix/issue-182-removesuffix-empty

Conversation

@abhinavkr26104

Copy link
Copy Markdown

Summary

  • guard suffix removal against the empty-suffix slicing edge case
  • compare both compatibility helpers with the Python standard library
  • cover matching, non-matching, empty-affix, and empty-input cases

Why

string[:-len(suffix)] becomes string[:0] for an empty suffix, returning an empty string instead of preserving the input as str.removesuffix("") does.

Fixes #182

Testing

  • python -m pytest tests/test_utils/test_utils.py -q (8 passed)
  • python -m mypy src/browserbase/_utils/_utils.py tests/test_utils/test_utils.py
  • python -m pyright src/browserbase/_utils/_utils.py tests/test_utils/test_utils.py
  • python -m ruff check src/browserbase/_utils/_utils.py tests/test_utils/test_utils.py
  • python -m ruff format --check src/browserbase/_utils/_utils.py tests/test_utils/test_utils.py
  • full suite: 1225 passed, 8 skipped; 4 pre-existing Windows/environment failures fixed separately by test: make suite deterministic on Windows #189
  • full suite excluding only the four test: make suite deterministic on Windows #189 cases: 1225 passed, 8 skipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

removesuffix helper returns an empty string for an empty suffix

1 participant