Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Ruff (Rust)

ruff-001 medium

Commit: f14fd5d885

Task prompt

Fix the Python formatter to preserve parentheses around exception handler tuples when any element is a starred expression (Python 3.14+). Without parentheses, a starred element in an except clause is parsed as except* (exception group syntax) rather than a tuple containing a starred element, changing semantics. Add a check for starred expressions in the tuple before removing parentheses.

ApproachTests PassPrecisionRecallF1DurationCost
no-bobbin100.0%31.7%33.3%32.4%4.3m$1.23
with-bobbin100.0%70.2%61.9%63.6%4.4m$1.52
with-bobbin+blame_bridging=false100.0%33.3%33.3%33.3%4.6m$1.25
with-bobbin+coupling_depth=0100.0%55.6%33.3%38.9%4.7m$1.45
with-bobbin+doc_demotion=0.0100.0%55.6%55.6%55.6%5.0m$1.48
with-bobbin+gate_threshold=1.0100.0%77.8%55.6%61.1%5.4m$1.39
with-bobbin+recency_weight=0.0100.0%77.8%55.6%61.1%4.9m$1.43
with-bobbin+semantic_weight=0.0100.0%23.6%33.3%25.2%4.7m$1.45

ruff-001_f1_boxplot.svg

ruff-001_duration.svg

Ground truth files: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/try.py, crates/ruff_python_formatter/src/other/except_handler_except_handler.rs, crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap

Files touched (no-bobbin): crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_except_types_parens.py, crates/ruff_python_formatter/src/other/except_handler_except_handler.rs, crates/ruff_python_formatter/tests/snapshots/black_compatibility@cases__remove_except_types_parens.py.snap Files touched (with-bobbin): crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/try.py, crates/ruff_python_formatter/src/other/except_handler_except_handler.rs, crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap Files touched (with-bobbin+blame_bridging=false): crates/ruff_python_formatter/resources/test/fixtures/ruff/except_handler_starred.py, crates/ruff_python_formatter/src/other/except_handler_except_handler.rs, crates/ruff_python_formatter/tests/snapshots/format@except_handler_starred.py.snap Files touched (with-bobbin+coupling_depth=0): crates/ruff_python_formatter/src/other/except_handler_except_handler.rs Files touched (with-bobbin+doc_demotion=0.0): crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/try.py, crates/ruff_python_formatter/src/other/except_handler_except_handler.rs, crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap Files touched (with-bobbin+gate_threshold=1.0): crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/try.py, crates/ruff_python_formatter/src/other/except_handler_except_handler.rs, crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap Files touched (with-bobbin+recency_weight=0.0): crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/try.py, crates/ruff_python_formatter/src/other/except_handler_except_handler.rs, crates/ruff_python_formatter/tests/snapshots/format@statement__try.py.snap Files touched (with-bobbin+semantic_weight=0.0): crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_except_types_parens.py, crates/ruff_python_formatter/resources/test/fixtures/black/cases/remove_except_types_parens.py.expect, crates/ruff_python_formatter/src/other/except_handler_except_handler.rs


ruff-002 easy

Commit: ddeadcbd18

Task prompt

Add multiprocessing.Value to the list of functions excluded from the flake8-boolean-trap rule FBT003. The Value constructor commonly takes a boolean as its second argument (e.g., Value("b", False)), and this is a legitimate use case that should not trigger a boolean positional argument warning. Implement a new is\_semantically\_allowed\_func\_call helper that uses qualified name resolution to match the call, and integrate it into the existing allow\_boolean\_trap logic.

ApproachTests PassPrecisionRecallF1DurationCost
no-bobbin100.0%100.0%40.0%57.1%4.8m$0.00
with-bobbin100.0%100.0%40.0%57.1%4.3m$1.38

ruff-002_f1_boxplot.svg

ruff-002_duration.svg

Ground truth files: crates/ruff_linter/resources/test/fixtures/flake8_boolean_trap/FBT.py, crates/ruff_linter/src/rules/flake8_boolean_trap/helpers.rs, crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap, crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap, crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__extend_allowed_callable.snap

Files touched (no-bobbin): crates/ruff_linter/resources/test/fixtures/flake8_boolean_trap/FBT.py, crates/ruff_linter/src/rules/flake8_boolean_trap/helpers.rs Files touched (with-bobbin): crates/ruff_linter/resources/test/fixtures/flake8_boolean_trap/FBT.py, crates/ruff_linter/src/rules/flake8_boolean_trap/helpers.rs


ruff-003 medium

Commit: 80dbc62a76

Task prompt

Fix the pylint PLC2701 (import-private-name) rule in two ways: (1) Stop flagging dunder submodules like \_\_main\_\_ as private imports by using the is\_dunder helper instead of a simple starts\_with("\_\_") check, which incorrectly matched dunder names. (2) Improve diagnostic ranges to point at the exact private name segment rather than the entire import binding, using a tokenizer to locate the private segment in module paths and alias name ranges for imported members.

ApproachTests PassPrecisionRecallF1DurationCost
no-bobbin100.0%100.0%83.3%90.0%9.2m$0.00
with-bobbin100.0%100.0%77.8%86.7%6.3m$1.92

ruff-003_f1_boxplot.svg

ruff-003_duration.svg

Ground truth files: crates/ruff_linter/resources/test/fixtures/pylint/import_private_name/submodule/__main__.py, crates/ruff_linter/src/rules/pylint/rules/import_private_name.rs, crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap

Files touched (no-bobbin): crates/ruff_linter/resources/test/fixtures/pylint/import_private_name/submodule/__main__.py, crates/ruff_linter/src/rules/pylint/rules/import_private_name.rs, crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap Files touched (with-bobbin): crates/ruff_linter/resources/test/fixtures/pylint/import_private_name/submodule/__main__.py, crates/ruff_linter/src/rules/pylint/rules/import_private_name.rs, crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap


ruff-004 easy

Commit: ceb876b823

Task prompt

Fix inconsistent handling of forward references (stringized annotations) in the flake8-pyi PYI034 rule for \_\_new\_\_, \_\_enter\_\_, and \_\_aenter\_\_ methods. Previously, return type annotations using forward references like def \_\_new\_\_(cls) -> "MyClass" were not detected, while non-stringized versions were. Add a new is\_name\_or\_stringized\_name helper that uses match\_maybe\_stringized\_annotation to resolve both plain and stringized annotations, and use it for the return type checks.

ApproachTests PassPrecisionRecallF1DurationCost
no-bobbin100.0%46.7%66.7%54.2%3.9m$0.00
with-bobbin100.0%63.3%83.3%70.8%4.5m$1.67

ruff-004_f1_boxplot.svg

ruff-004_duration.svg

Ground truth files: crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI034.py, crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs, crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap

Files touched (no-bobbin): crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI034.py, crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI034.pyi, crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs, crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap, crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap Files touched (with-bobbin): crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI034.py, crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs, crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap


ruff-005 easy

Commit: aa9c9bf01f

Task prompt

Suppress diagnostic output when running ruff format --check --silent. The --silent flag was not being respected in format check mode, causing “Would reformat” messages to still appear. Fix by wrapping the output-writing match block in a log\_level > LogLevel::Silent guard so that no stdout output is produced in silent mode. Add integration tests for both --silent and --quiet modes to verify correct output behavior.

ApproachTests PassPrecisionRecallF1DurationCost
no-bobbin100.0%100.0%100.0%100.0%3.6m$0.00
with-bobbin100.0%100.0%100.0%100.0%2.8m$0.63

ruff-005_f1_boxplot.svg

ruff-005_duration.svg

Ground truth files: crates/ruff/src/commands/format.rs, crates/ruff/tests/cli/format.rs

Files touched (no-bobbin): crates/ruff/src/commands/format.rs, crates/ruff/tests/cli/format.rs Files touched (with-bobbin): crates/ruff/src/commands/format.rs, crates/ruff/tests/cli/format.rs