What's Changed
Highlights
This release includes full support for Python 3.12 (out now!), including the new type parameter (PEP 695) and f-string syntaxes (PEP 701).
PEP 701 lifts many of the restrictions on f-strings that existed in the past, allowing for arbitrarily nested f-strings, consistent quote style within f-strings, and more, all of which are now supported by Ruff (thanks to @dhruvmanila in #7376).
Breaking Changes
- In the formatter,
format.quote-style
no longer affects triple-quoted strings, to align with common conventions as well as the guidance from PEP 8 and PEP 257 (see: #7680). line-too-long
(E501
) now ignores trailing pragma comments (like# type: ignore
and# noqa
) when computing line length (see: #7692). This is similar to flake8-bugbear's methodology for detecting overlong lines, and ensures that adding pragmas like# noqa
does not introduce further lint errors.
Rules
- [
refurb
] Implementprint-empty-string
(FURB105
) by @tjkuson in #7617 - [
flake8-bandit
] Implementweak-cryptographic-key
(S505
) by @mkniewallner in #7703 - [
refurb
] Implementimplicit-cwd
(FURB177
) by @danparizher in #7704 unnecessary-pass
(PIE790
) now flags all unnecessarypass
statements; previously, the rule only flaggedpass
statements that followed a docstring in a two-statement body (see: #7697).
Settings
- Add
lint
section to Ruff configuration by @MichaReiser in #7549 - Add
explicit-preview-rules
to toggle explicit selection of preview rules by @zanieb in #7390 - Decrease PEP 593 error to a debug warning by @charliermarsh in #7745
- Write full Jupyter notebook to
stdout
by @charliermarsh in #7748 - Extend
unnecessary-pass
(PIE790
) to trigger on all unnecessarypass
statements by @tjkuson in #7697
Bug Fixes
- Ignore blank lines between comments when counting newlines-after-imports by @charliermarsh in #7607
- Avoid reordering mixed-indent-level comments after branches by @charliermarsh in #7609
- Avoid flagging B009 and B010 on starred expressions by @charliermarsh in #7621
- Use deletion for D215 full-line removals by @charliermarsh in #7625
- Avoid searching for bracketed comments in unparenthesized generators by @charliermarsh in #7627
- Update return type for
PT022
autofix by @dhruvmanila in #7613 - Flag FURB105 with starred kwargs by @charliermarsh in #7630
- Don't suggest replacing
builtin.open()
withPath.open()
if the latter doesn't support all options by @konstin in #7637 - Use 1-based cell indices consistently for Notebooks by @dhruvmanila in #7662
- Add
Expr::Name
checks to rules which useis_logger_candidate
by @qdegraaf in #7521 - Ensure that B006 autofixes are inserted after imports by @Hoxbro in #7629
- Allow named expressions in
__all__
assignments by @charliermarsh in #7673 - Include radix base prefix in large number representation by @charliermarsh in #7700
- Parenthesize multi-line attributes in B009 by @charliermarsh in #7701
- Insert necessary padding in B014 fixes by @charliermarsh in #7699
- fix(rules): improve S507 detection by @mkniewallner in #7661
- Ignore TODO tags in
commented-out-code
by @tjkuson in #7523 - Track fix isolation in
unnecessary-pass
by @charliermarsh in #7715 - Use fixed source code for parser context by @charliermarsh in #7717
- Preserve parentheses in
quadratic-list-summation
by @charliermarsh in #7719 - Compute
NotebookIndex
forDiagnostics
on stdin by @dhruvmanila in #7663 - Perform insertions before replacements by @charliermarsh in #7739
- Skip all bracketed expressions when locating comparison ops by @charliermarsh in #7740
- Fix PLE251 rules with f-string escaping by @konstin in #7741
- Skip BOM when inserting start-of-file imports by @charliermarsh in #7622
- Emit
LexError
for dedent to incorrect level by @MichaReiser in #7638 - Expand
DeprecatedLogWarn
to check forExpr::Atrribute
calls by @qdegraaf in #7677
Other Changes
- Add support for PEP 701 by @dhruvmanila in #7376
- Improve performance of
commented-out-code
(~50-80%) by @charliermarsh in #7706
New Contributors
- @bluthej made their first contribution in #7665
- @Hoxbro made their first contribution in #7629
- @danparizher made their first contribution in #7704
- @aspizu made their first contribution in #7750
Full Changelog: v0.0.291...v0.0.292