ruff/crates
Brent Westbrook 591e9bbccb
Remove parentheses around multiple exception types on Python 3.14+ (#20768)
Summary
--

This PR implements the black preview style from
https://github.com/psf/black/pull/4720. As of Python 3.14, you're
allowed to omit the parentheses around groups of exceptions, as long as
there's no `as` binding:

**3.13**

```pycon
Python 3.13.4 (main, Jun  4 2025, 17:37:06) [Clang 20.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> try: ...
... except (Exception, BaseException): ...
...
Ellipsis
>>> try: ...
... except Exception, BaseException: ...
...
  File "<python-input-1>", line 2
    except Exception, BaseException: ...
           ^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized
```

**3.14**

```pycon
Python 3.14.0rc2 (main, Sep  2 2025, 14:20:56) [Clang 20.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> try: ...
... except Exception, BaseException: ...
...
Ellipsis
>>> try: ...
... except (Exception, BaseException): ...
...
Ellipsis
>>> try: ...
... except Exception, BaseException as e: ...
...
  File "<python-input-2>", line 2
    except Exception, BaseException as e: ...
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized when using 'as'
```

I think this ended up being pretty straightforward, at least once Micha
showed me where to start :)

Test Plan
--

New tests

At first I thought we were deviating from black in how we handle
comments within the exception type tuple, but I think this applies to
how we format all tuples, not specifically with the new preview style.
2025-10-14 11:17:45 -04:00
..
ruff Bump 0.14.0 (#20751) 2025-10-07 11:05:47 -07:00
ruff_annotate_snippets Display diffs for ruff format --check and add support for different output formats (#20443) 2025-09-30 12:00:51 -04:00
ruff_benchmark Shard ty walltime benchmarks (#20791) 2025-10-10 07:55:50 +02:00
ruff_cache
ruff_db Render unsupported syntax errors in formatter tests (#20777) 2025-10-13 10:00:37 -04:00
ruff_dev [ty] Document when a rule was added (#20859) 2025-10-14 14:33:48 +02:00
ruff_diagnostics
ruff_formatter Display diffs for ruff format --check and add support for different output formats (#20443) 2025-09-30 12:00:51 -04:00
ruff_graph
ruff_index
ruff_linter Fix false negatives in Truthiness::from_expr for lambdas, generators, and f-strings (#20704) 2025-10-14 03:06:17 -05:00
ruff_macros Replace two more uses of unsafe with const Option::unwrap (#20584) 2025-09-25 15:35:13 -04:00
ruff_memory_usage [ty] Clean up inherited generic contexts (#20647) 2025-10-03 13:55:43 -04:00
ruff_notebook Display diffs for ruff format --check and add support for different output formats (#20443) 2025-09-30 12:00:51 -04:00
ruff_options_metadata
ruff_python_ast Fix false negatives in Truthiness::from_expr for lambdas, generators, and f-strings (#20704) 2025-10-14 03:06:17 -05:00
ruff_python_ast_integration_tests
ruff_python_codegen Generator preferred quote style (#20434) 2025-09-18 12:57:21 +02:00
ruff_python_formatter Remove parentheses around multiple exception types on Python 3.14+ (#20768) 2025-10-14 11:17:45 -04:00
ruff_python_importer [ruff] Add API for splicing into an existing import statement 2025-09-17 13:59:28 -04:00
ruff_python_index Track t-strings and f-strings for token-based rules and suppression comments (#20357) 2025-09-12 13:00:12 -05:00
ruff_python_literal
ruff_python_parser [syntax-errors]: break outside loop F701 (#20556) 2025-10-13 20:00:59 +00:00
ruff_python_semantic [ruff] Extend FA102 with listed PEP 585-compatible APIs (#20659) 2025-10-03 09:45:32 -04:00
ruff_python_stdlib [ruff] Extend FA102 with listed PEP 585-compatible APIs (#20659) 2025-10-03 09:45:32 -04:00
ruff_python_trivia Handle t-string prefixes in SimpleTokenizer (#20578) 2025-09-25 14:33:37 -05:00
ruff_python_trivia_integration_tests Handle t-string prefixes in SimpleTokenizer (#20578) 2025-09-25 14:33:37 -05:00
ruff_server Use Annotation::tags instead of hardcoded rule matching in ruff server (#20565) 2025-09-26 09:06:26 +02:00
ruff_source_file
ruff_text_size [ruff] Add TextRange::to_std_range 2025-09-17 13:59:28 -04:00
ruff_wasm Bump 0.14.0 (#20751) 2025-10-07 11:05:47 -07:00
ruff_workspace Update lint.flake8-type-checking.quoted-annotations docs (#20765) 2025-10-14 06:43:24 +00:00
ty [ty] Document when a rule was added (#20859) 2025-10-14 14:33:48 +02:00
ty_combine
ty_completion_eval [ty] Add an evaluation for completions 2025-10-08 08:44:21 -04:00
ty_ide [ty] defer inference of legacy TypeVar bound/constraints/defaults (#20598) 2025-10-09 21:08:37 +00:00
ty_project [ty] Use 3.14 as the default version (#20759) 2025-10-08 11:38:47 +02:00
ty_python_semantic [ty] Fix further issues in super() inference logic (#20843) 2025-10-14 12:48:47 +00:00
ty_server [ty] Improve diagnostics for bad @overload definitions (#20745) 2025-10-07 21:52:57 +00:00
ty_static [ty] improve base conda distinction from child conda (#20675) 2025-10-03 13:56:06 +00:00
ty_test [ty] Filter out revealed-type and undefined-reveal diagnostics from mdtest snapshots (#20820) 2025-10-12 18:39:32 +00:00
ty_vendored [ty] Sync vendored typeshed stubs (#20658) 2025-10-01 10:11:48 +02:00
ty_wasm [ruff,ty] Enable tracing's log feature 2025-10-03 08:18:03 -04:00