mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:47 +00:00
![]() ## Summary This review contains a fix for [PIE810](https://docs.astral.sh/ruff/rules/multiple-starts-ends-with/) (multiple-starts-ends-with) The problem is that ruff suggests combining multiple startswith/endswith calls into a single call even though there might be a call with tuple of strs. This leads to calling startswith/endswith with tuple of tuple of strs which is incorrect and violates startswith/endswith conctract and results in runtime failure. However the following will be valid and fixed correctly => ```python x = ("hello", "world") y = "h" z = "w" msg = "hello world" if msg.startswith(x) or msg.startswith(y) or msg.startswith(z) : sys.exit(1) ``` ``` ruff --fix --select PIE810 --unsafe-fixes ``` => ```python if msg.startswith(x) or msg.startswith((y,z)): sys.exit(1) ``` See: https://github.com/astral-sh/ruff/issues/8906 ## Test Plan ```bash cargo test ``` |
||
---|---|---|
.. | ||
test | ||
__init__.py |