ruff/crates
Mikko Leppänen b9139a31d5
[flake8-pie] Omit bound tuples passed to .startswith or .endswith (#9661)
## 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
```
2024-01-28 19:29:04 +00:00
..
ruff help: enable auto-wrapping of help output (#9633) 2024-01-24 10:51:07 -05:00
ruff_benchmark Approximate tokens len (#9546) 2024-01-19 17:39:37 +01:00
ruff_cache Make all dependencies workspace dependencies (#9333) 2024-01-02 13:41:59 +00:00
ruff_dev help: enable auto-wrapping of help output (#9633) 2024-01-24 10:51:07 -05:00
ruff_diagnostics Enable annotation quoting for multi-line expressions (#9142) 2023-12-15 01:03:09 +00:00
ruff_formatter --show-settings displays active settings in a far more readable format (#9464) 2024-01-12 14:30:29 -05:00
ruff_index Make all dependencies workspace dependencies (#9333) 2024-01-02 13:41:59 +00:00
ruff_linter [flake8-pie] Omit bound tuples passed to .startswith or .endswith (#9661) 2024-01-28 19:29:04 +00:00
ruff_macros remove several uses of unsafe (#8600) 2023-11-28 09:50:03 -05:00
ruff_notebook Generate deterministic ids when formatting notebooks (#9359) 2024-01-04 09:19:00 -06:00
ruff_python_ast Delete is_node_with_body method (#9643) 2024-01-25 14:41:13 +00:00
ruff_python_codegen Remove source path from parser errors (#9322) 2023-12-30 20:33:05 +00:00
ruff_python_formatter Preserve indent around multiline strings (#9637) 2024-01-26 08:18:30 +01:00
ruff_python_index Approximate tokens len (#9546) 2024-01-19 17:39:37 +01:00
ruff_python_literal Use Rust 1.75 toolchain (#9437) 2024-01-08 18:03:16 +01:00
ruff_python_parser Approximate tokens len (#9546) 2024-01-19 17:39:37 +01:00
ruff_python_resolver Use Rust 1.75 toolchain (#9437) 2024-01-08 18:03:16 +01:00
ruff_python_semantic [tryceratops] Add fix for error-instead-of-exception (TRY400) (#9520) 2024-01-16 03:00:04 +00:00
ruff_python_stdlib Add an explicit fast path for whitespace to is_identifier_continuation (#9532) 2024-01-16 08:23:43 +00:00
ruff_python_trivia Add an explicit fast path for whitespace to is_identifier_continuation (#9532) 2024-01-16 08:23:43 +00:00
ruff_shrinking Bump version to v0.1.14 (#9581) 2024-01-19 12:54:39 -05:00
ruff_source_file Add cell indexes to all diagnostics (#9387) 2024-01-04 14:02:23 +00:00
ruff_text_size Make all dependencies workspace dependencies (#9333) 2024-01-02 13:41:59 +00:00
ruff_wasm Approximate tokens len (#9546) 2024-01-19 17:39:37 +01:00
ruff_workspace [pylint] Implement too-many-nested-blocks (PLR1702) (#9172) 2024-01-24 19:30:01 +00:00