Releases: astral-sh/ruff
v0.0.287
What's Changed
Rules
- [refurb] Implement preview
repeated-append
rule (FURB113
) by @SavchenkoValeriy in #6702 - [refurb] Implement preview
delete-full-slice
rule (FURB131
) by @SavchenkoValeriy in #6897 - [refurb] Implement preview
check-and-remove-from-set
rule (FURB132
) by @SavchenkoValeriy in #6904
Bug Fixes
- Expand
PERF401
andPERF402
with type checks by @qdegraaf in #6994 - Insert space to avoid syntax error in RSE fixes by @charliermarsh in #6886
- Avoid PEP 604 upgrades that lead to invalid syntax by @charliermarsh in #6888
- Fix ranges for global usages by @charliermarsh in #6917
- Avoid invalid fix for C417 with separate keys and values by @charliermarsh in #6954
- Avoid panic when
typename
is provided as a keyword argument by @charliermarsh in #6955 - Improve compatibility between multi-statement PYI rules by @charliermarsh in #7024
- Fixed panic in
missing_copyright_notice
by @WindowGenerator in #7029 - Avoid lexer infinite loop on invalid input by @dhruvmanila in #6937
- Fix
WithItem
ranges for parenthesized, non-as
items by @charliermarsh in #6782
New Contributors
- @SavchenkoValeriy made their first contribution in #6702
- @Anselmoo made their first contribution in #6986
- @njgrisafi made their first contribution in #7032
- @WindowGenerator made their first contribution in #7029
Full Changelog: v0.0.286...v0.0.287
v0.0.286
What's Changed
New Rules
- [
flake8-bugbear
] Updatefunction-call-in-argument-default
(B008
) to ignore arguments with immutable annotations by @zanieb in #6784 - [
flake8-bugbear
] Updatemutable-argument-default
(B006
) to useextend-immutable-calls
when determining if annotations are immutable by @zanieb in #6781 - [
flake8-pie
] Implementunnecessary-range-start
(PIE808
) by @harupy in #6690 - [
flake8-pytest-style
] Add autofix forPT014
by @harupy in #6698 - [
pylint
] Implementno-self-use
(R6301
) by @LaBatata101 in #6574 - [
pylint
] Extendrepeated-equality-comparison-target
to check for mixed orderings and Yoda conditions. by @tjkuson in #6691
Settings
- Make isort's
detect-same-package
behavior configurable by @charliermarsh in #6833
Bug Fixes
- Apply RUF017 when start is passed via position by @hauntsaninja in #6664
- Use
typing_extensions.TypeAlias
for PYI026 fixes on pre-3.10 by @charliermarsh in #6696 - Ignore multi-comparisons in
repeated-equality-comparison-target
by @charliermarsh in #6705 - Accept empty inner calls in C414 by @charliermarsh in #6725
- Allow next in FBT exclusions by @charliermarsh in #6729
- Allow
ctypes.WinError()
in flake8-raise by @charliermarsh in #6731 - Ignore star imports when importing symbols in fixes by @charliermarsh in #6743
- Support C419 autofixes for set comprehensions by @charliermarsh in #6744
- Avoid attempting to fix unconventional submodule imports by @charliermarsh in #6745
- Don't trigger
eq-without-hash
when__hash__
is explicitly set toNone
by @LaBatata101 in #6739 - Avoid E231 if comma is at end-of-line by @charliermarsh in #6747
- Truncate some messages in diagnostics by @charliermarsh in #6748
- Fix isolation groups for unused imports by @charliermarsh in #6774
- Avoid fixing D200 for docstrings that end in escapes by @charliermarsh in #6779
- Parenthesize expressions prior to LibCST parsing by @charliermarsh in #6742
- Fallback to end-of-file if ends in trailing continuation by @charliermarsh in #6789
- Confine repeated-equality-comparison-target to names and attributes by @charliermarsh in #6802
- Fix
native-literals
handling of int literal with attribute access by @zanieb in #6792 - Fix
uncessary-coding-comment
fix when there's leading content by @zanieb in #6775 - Avoid attempting to fix PT018 in multi-statement lines by @charliermarsh in #6829
- Update ERA100 to apply to commented dictionary items with trailing comments by @zanieb in #6822
- Avoid parsing other parts of a format specification if replacements are present by @zanieb in #6858
- Avoid panic in unused arguments rule for parameter-free lambda by @charliermarsh in #6679
- Avoid
C417
forlambda
with default and variadic parameters by @dhruvmanila in #6752 - Add
networkx
to conventional aliases by @zanieb in #6778 - Skip serializing cell ID if it's None by @harupy in #6851
- fix is_raw_string for multiple prefixes by @davidszotten in #6865
- Add jupyter notebook cell ids in 4.5+ if missing by @konstin in #6853
Full Changelog: v0.0.285...v0.0.286
v0.0.285
What's Changed
New rules
- [
flake8-pytest-style
] Implementpytest-unittest-raises-assertion
(PT027
) by @harupy in #6554 - [
flake8-pytest-style
] Implementpytest-duplicate-parametrize-test-cases
(PT014
) by @harupy in #6598 - [
flake8-tidy-imports
] Implementbanned-module-level-imports
(TID253
) by @durumu in #6378 - [
pylint
] Implementbad-dunder-name
(W3201
) (in the Ruff nursery) by @LaBatata101 in #6486 - [
pylint
] Implementsubprocess-run-check
(W1510
) by @tjkuson in #6487 - [
ruff
] Implementquadratic-list-summation
(RUF017
) by @evanrittenhouse in #6489
Rule changes
- [
flake8-bugbear
] Add autofix forB006
by @qdegraaf in #6131 - [
flake8-pyi
] Avoid applyingPYI055
to runtime-evaluated annotations by @charliermarsh in #6457 - [
flake8-self
] Allowos._exit
accesses inSLF001
by @charliermarsh in #6490 - [
perflint
] IgnorePERF203
iftry
contains loop control flow statements by @evanrittenhouse in #6536 - [
pylint
] Check for invalid format type specifiers in nested replacements forPLE1300
by @zanieb in #6616 - [
tryceratops
] OmitNotImplementedError
fromTRY003
by @charliermarsh in #6568
Settings
- Respect
.ipynb
and.pyi
sources when linting from stdin by @charliermarsh in #6628 - Support glob patterns for
raises_require_match_for
andraises_require_match_for
by @harupy in #6635
Bug Fixes
- Make
lambda-assignment
fix always-manual in class bodies by @charliermarsh in #6626 - Fix counting of message arguments when msg is provided as a keyword by @charliermarsh in #6456
- Add container types to
E721
by @charliermarsh in #6469 - Respect scoping rules when identifying builtins by @charliermarsh in #6468
- Respect tab width in line-length heuristic by @charliermarsh in #6491
- Respect dummy-variable-rgx for unused bound exceptions by @charliermarsh in #6492
- Fix detection of top-level imports with newlines in
E402
by @charliermarsh in #6526 - Allow if-expression with dual string arms in
invalid-envvar-value
by @charliermarsh in #6538 - Add deprecated unittest assertions to PT009 by @charliermarsh in #6572
- Avoid unused argument rules when functions call
locals()
by @charliermarsh in #6578 - Allow top-level
await
in Jupyter notebooks by @charliermarsh in #6607 - Don't detect
pandas#values
for stores, deletes, or class accesses by @charliermarsh in #6631 - Avoid removing parentheses in
E712
fix by @charliermarsh in #6575 - Skip whitespace between comments at start of file e.g. for
I002
by @durumu in #6523 - Add support for nested replacements inside format specifications e.g. for
PLE1300
by @zanieb in #6616
Playground
- Shared playground links now use short URLs by @charliermarsh in #6383
- Fix possible JSON parse error on playground load by @charliermarsh in #6519
- Fix unreachable panic in playground by @MichaReiser in #6623
Performance
- Improve tokenizer performance for ASCII only identifiers by @MichaReiser in #6609
New Contributors
- @magic-akari made their first contribution in #6472
- @durumu made their first contribution in #6378
- @jamesbraza made their first contribution in #6520
- @takumaw made their first contribution in #6533
- @noklam made their first contribution in #6573
- @Teraskull made their first contribution in #6605
Full Changelog: v0.0.284...v0.0.285
v0.0.284
What's Changed
This release fixes a few bugs. Notably, the previous release announced a breaking change where the default target
Python version changed from 3.10 to 3.8 but the change was not applied. Thanks to @rco-ableton for fixing this in
#6444
Bug Fixes
- Do not trigger
S108
if path is insidetempfile.*
call by @dhruvmanila in #6416 - Do not allow on zero tab width by @tjkuson in #6429
- Fix false-positive in submodule resolution by @charliermarsh in #6435
New Contributors
- @rco-ableton made their first contribution in #6444
Full Changelog: v0.0.283...v0.0.284
v0.0.283
What's Changed
Breaking Changes
Rules
- [
flake8-pyi
]PYI019
: Detects if a type variable is used instead ofSelf
in return annotations by @qdegraaf in #6204 - [
flake8-pyi
]PYI051
: Detects unions ofLiteral
types by @LaBatata101 in #6215 - [
flake8-pyi
]PYI055
: Detects unions oftype
s by @LaBatata101 in #6316 - [
pylint
]E1300
: Detects invalid string format characters by @silvanocerza in #6171 - [
pyupgrade
]UP040
: Upgrades type alias annotations to use PEP-695 syntax by @zanieb in #6289
Rule Changes
- [
flake8-boolean-trap
]FBT003
: Addis_
andis_not
to excluded functions by @zanieb in #6307 - [
flake8-logging-format
] Allow capitalized names for logger candidate heuristic match by @charliermarsh in #6356 - [
flake8-pyi
] Applicable rules are now checked non-stub code by @andersk in #6297PYI013
:ellipsis-in-non-empty-class-body
PYI016
:duplicate-union-member
PYI018
:unused-private-type-var
PYI019
:custom-type-var-return-type
PYI024
:collections-named-tuple
PYI025
:unaliased-collections-abc-set-import
PYI030
:unnecessary-literal-union
PYI032
:any-eq-ne-annotation
PYI034
:non-self-return-type
PYI036
:bad-exit-annotation
PYI041
:redundant-numeric-union
PYI042
:snake-case-type-alias
PYI043
:t-suffixed-type-alias
PYI045
:iter-method-return-iterable
PYI046
:unused-private-protocol
PYI047
:unused-private-type-alias
PYI049
:unused-private-typed-dict
PYI050
:no-return-argument-annotation-in-stub
(Python ≥ 3.11)PYI051
:redundant-literal-union
PYI056
:unsupported-method-call-on-all
- [
flake8-pyi
]PYI027
is being replaced byPYI022
/UP035
by @LaBatata101 in #6354 - [
pydocstyle
]D103
: Don't require docstrings in.pyi
files by @charliermarsh in #6239 - [
pydocstyle
]D203
: Ignore same-line docstrings for lines-before and lines-after rules by @charliermarsh in #6344 - [
pylint
]PLE0605
: Allow generic tuple and list calls in__all__
by @charliermarsh in #6247 - [
pylint
]PLR0124
: Add detection of comparisons with built-in calls by @charliermarsh in #6324 - [
pyupgrade
]UP032
: Add support forawait
expressions in f-strings by @harupy in #6304 - [
pyupgrade
]UP032
: Add support for implicitly concatenated strings by @harupy in #6263 - [
pyupgrade
]UP032
: Add support for repeated format fields by @harupy in #6266 - [
ruff
]RUF012
: PermitClassVar
andFinal
without subscript by @bluetech in #6273
Bug Fixes
- [
flake8-bugbear
]B006
: Respecttyping_extensions
imports ofAnnotated
by @PIG208 in #6361 - [
flake8-pyi
]PYI019
: Fix panic with positional-only arguments by @charliermarsh in #6350 - [
flake8-use-pathlib
] Avoid raisingPTH206
withmaxsplit
by @charliermarsh in #6283 - [
flake8
]F841
: Update autofix to not remove Jupyer magic expressions by @dhruvmanila in #6141 - [
pycodestyle
]E721
: Include comparisons to builtin types by @charliermarsh in #6325 - [
pycodestyle
]E721
: Match left-hand sidetypes()
call intypes-comparison
by @charliermarsh in #6326 - [
pyupgrade
]UP031
: Avoid auto-fixing if there are comments within the right-hand side by @harupy in #6364 - [
pyupgrade
]UP032
: Avoid auto-fixing if comments are present around format call arguments by @harupy in #6342 - [
pyupgrade
]UP032
: Improve invalid expression check by @harupy in #6308 - Avoid attempting to fix
.format(...)
calls with too-few-arguments by @charliermarsh in #6401 - Fix bug where
.gitignore
files in parent directories were incorrectly used by @charliermarsh in #6368 - Fix duplicate violations raised on nested bitwise or
Union
expressions by @charliermarsh in #6399
Playground
- Add a simple tooltip to the sidebar by @charliermarsh in #6295
- Add an icon for FIR by @charliermarsh in #6292
- Increase icon opacity on-hover by @charliermarsh in #6291
- Tweak background on theme button by @charliermarsh in #6290
Other Changes
- Improve handling of violations around Jupyter magic expressions by @dhruvmanila in #5552
- Reduce memory usage by boxing type params and arguments fields on the class definition node by @charliermarsh in #6275
- Upgrade Rust to 1.71 by @zanieb in #6323
New Contributors
- @silvanocerza made their first contribution in #6171
- @PIG208 made their first contribution in #6361
Full Changelog: v0.0.282...v0.0.283
v0.0.282
What's Changed
Bug Fixes
- Reset model state when exiting deferred visitors by @charliermarsh in #6208
- Skip trivia when searching for named exception by @charliermarsh in #6218
- Avoid PERF401 false positive on list access in loop by @charliermarsh in #6220
- Avoid detecting continuations at non-start-of-line by @charliermarsh in #6219
- Revert "Expand scope of
quoted-annotation
rule (#5766)" by @charliermarsh in #6237
New Contributors
Full Changelog: v0.0.281...v0.0.282
v0.0.281
What's Changed
See the release blog post for more, including detailed descriptions of any newly added rules.
New rules
- [
flake8-pyi
] ImplementPYI018
by @LaBatata101 in #6018 - [
flake8-pyi
] ImplementPYI047
by @LaBatata101 in #6134 - [
flake8-pyi
] ImplementPYI049
by @LaBatata101 in #6136 - [
flake8-pyi
] ImplementPYI056
by @LaBatata101 in #5959 - [
flake8-pyi
] ImplementPYI046
by @LaBatata101 in #6098 - [
flake8-use-pathlib
] Implementglob
(PTH207
) by @sbrugman in #5939 - [
flake8-use-pathlib
] Implementos-sep-split
(PTH206
) by @sbrugman in #5936 - [
pycodestyle
] ImplementE241
andE242
(tab/multiple ws after commas) by @akx in #6094 - [
pylint
] Implementself-assigning-variable
(W0127
) by @tjkuson in #6015 - [
pylint
] Implementeq-without-hash
rule (PLW1641) by @jelly in #5955 - [
pylint
] Implementsubprocess-popen-preexec-fn
(W1509
) by @tjkuson in #5978
Rule changes
- [
flake8-bugbear
] ExtendsB002
to detect unary prefix decrement operators by @tjkuson in #5998 - [
flake8-pytest-style
] Avoid raising PT012 for simplewith
statements by @harupy in #6081 - [
flake8-pytest-style
] Allow pytest.raises body to contain a single func or class definition by @harupy in #6083 - [
flake8-simplify
] Extend SIM118 withnot in
by @sbrugman in #5995 - [
perflint
] SkipPERF203
violations for multi-statement loops by @charliermarsh in #6145 - [
pyupgrade
] Add support forint
,float
,bool
inUP018
by @dhruvmanila in #6013 - [
tryceratops
] Add suggested fix forTRY201
by @dhruvmanila in #6008
Settings
- Allow specification of
logging.Logger
re-exports vialogger-objects
by @charliermarsh in #5750 - Set default
max-complexity
to 10 for empty McCabe settings by @charliermarsh in #6073 - [
pep8-naming
]: New config optionextend-ignore-names
by @dhruvmanila in #6169
Bug Fixes
- Avoid raising
UP032
ifformat
call arguments contain multiline expressions by @harupy in #5971 - Fix
F507
false positive by @harupy in #5986 - Fix logging rules with whitespace around dot by @charliermarsh in #6022
- Ignore end-of-line comments when dirtying if-with-same-arms branches by @charliermarsh in #6031
- Avoid treating
Literal
members as expressions with__future__
by @charliermarsh in #6032 - Avoid refactoring
x[:1]
-like slices in RUF015 by @charliermarsh in #6150 - Avoid key-in-dict violations for
self
accesses by @charliermarsh in #6165 - Avoid falsely marking non-submodules as submodule aliases by @charliermarsh in #6182
- Flag
[
as an invalid noqa suffix by @charliermarsh in #5982 - Ignore some common builtin overrides on standard library subclasses by @charliermarsh in #6074
- Avoid A003 violations for explicitly overridden methods by @charliermarsh in #6076
- Include file permissions in key for cached files by @zanieb in #5901
- Ignore
explicit-string-concatenation
on single line by @tjkuson in #6028 - Fix
SIM102
to handle indentedelif
by @harupy in #6072 - Raise
PTH201
forPath("")
by @harupy in #6095 - Update
SIM115
to coverpathlib.Path.open
by @harupy in #611 - Ignore end-of-line file exemption comments by @charliermarsh in #6160
- Implement
--diff
for Jupyter Notebooks by @dhruvmanila in #6149 - Skip BOM when determining Locator's line starts by @charliermarsh in #6159
- Avoid parenthesizing comprehension element by @dhruvmanila in #6198
- Do not raise
SIM105
for non-exceptions by @sbrugman in #5985
New Contributors
- @AlexWaygood made their first contribution in #5973
- @RMPR made their first contribution in #6048
- @arembridge made their first contribution in #6079
- @Eutropios made their first contribution in #6082
- @jelly made their first contribution in #5955
Full Changelog: v0.0.280...v0.0.281
v0.0.280
What's Changed
Bug Fixes
- Avoid collapsing
elif
andelse
branches during import sorting by @charliermarsh in #5964
Full Changelog: v0.0.279...v0.0.280
v0.0.279
What's Changed
Rules
- [
flake8-pyi
] Implement flake8-pyi's PYI026 by @LaBatata101 in #5844 - [
flake8-pyi
] Implement flake8-pyi'sPYI017
by @qdegraaf in #5895 - [
flake8-pyi
] Implement flake8-pyi'sPYI036
by @density in #5668 - [
flake8-pyi
] Implement flake8-pyi'sPYI041
by @density in #5722 - [
flake8-use-pathlib
] Implementos-path-getsize
andos-path-get(a|m|c)-time
(PTH202-205
) by @sbrugman in #5835 - [
flake8-use-pathlib
] Implementpath-constructor-default-argument
(PTH201
) by @sbrugman in #5833 - [
pandas-vet
] Implement constant series rule (PD101
) by @sbrugman in #5802 - [
pylint
] Implement Pylint'sconsider-using-in
(PLR1714
) by @tjkuson in #5193
Rule changes
- [
flake8-annotations
] Check forAny
in other types forANN401
by @dhruvmanila in #5601 - [
flake8-bugbear
] Add autofix for B004 by @density in #5788 - [
flake8-bugbear
] RemoveB904
's lowercase exemption by @charliermarsh in #5751 - [
flake8-use-pathlib
] extend PTH118 withos.sep
by @sbrugman in #5935 - [
pyupgrade
] Expand scope ofquoted-annotation
rule (UP037
) by @charliermarsh in #5766 - [
pyupgrade
] Extend PEP 604 rewrites to support some quoted annotations by @charliermarsh in #5725 - [
ruff
] ExpandRUF015
to include all expression types by @charliermarsh in #5767
Bug Fixes
- Consider single element subscript expr for implicit optional by @dhruvmanila in #5717
- Ignore
Enum
-and-str
subclasses for slots enforcement by @charliermarsh in #5749 - Avoid removing raw strings in comparison fixes by @charliermarsh in #5755
- Fix nested calls to
sorted
with differing arguments by @density in #5761 - Use unused variable detection to power
incorrect-dict-iterator
by @charliermarsh in #5763 - Include alias when formatting import-from structs by @guillaumeLepape in #5786
- Make
lint_only
aware of the source kind by @dhruvmanila in #5876 - Restore
redefined-while-unused
violations in classes by @charliermarsh in #5926 - Flatten nested tuples when fixing UP007 violations by @charliermarsh in #5724
- Ignore Jupyter Notebooks for
--add-noqa
by @dhruvmanila in #5727 - Avoid checking
EXE001
andEXE002
on WSL by @tjkuson in #5735 - Properly group assignment targets by @MichaReiser in #5728
- Avoid stack overflow for non-BitOr binary types by @charliermarsh in #5743
- Move function visit out of
Expr::Call
branches by @charliermarsh in #5772 - [B006] Add bytes to immutable types by @harupy in #5776
- Format
SetComp
by @lkh42t in #5774 - Gate
runtime-import-in-type-checking-block
(TCH004
) behind enabled flag by @charliermarsh in #5789 - perf: only compute start offset for overlong lines by @sbrugman in #5811
- Change
pandas-use-of-dot-read-table
rule to emit only whenread_table
is used on CSV data by @tjkuson in #5807 - Do not fix
NamedTuple
calls containing both a list of fields and keywords by @harupy in #5799 - Ignore directories when collecting files to lint by @harupy in #5775
- Add filename to
noqa
warnings by @sobolevn in #5856 - Handle io errors gracefully by @konstin in #5611
- Allow
respect_gitignore
when not in a git repo by @dhruvmanila in #5937
New Contributors
- @eggplants made their first contribution in #5741
- @guillaumeLepape made their first contribution in #5786
- @odiseo0 made their first contribution in #5888
- @DavidCain made their first contribution in #5889
- @LaBatata101 made their first contribution in #5844
Full Changelog: v0.0.278...v0.0.279
v0.0.278
See the release blog post for more, including detailed descriptions of any newly added rules.
What's Changed
Rules
- [
pylint
] Implementtypevar-bivariance
(PLC0131
) by @tjkuson in #5517 - [
flake8-pyi
] Implementunnecessary-literal-union
(PYI030
) by @zanieb in #5570 - [
pylint
] Implementtype-name-incorrect-variance
(PLC0105
) by @tjkuson in #5651 - [
ruff
] Implementunnecessary-list-allocation-for-first-element
(RUF015
) by @evanrittenhouse in #5549 - [
flake8-bugbear
] Implementre-sub-positional-args
(B034
) by @charliermarsh in #5669 - [
ruff
] Implementinvalid-index-type
(RUF016
) by @zanieb in #5602
Settings
- [
isort
] Add--case-sensitive
flag by @qdegraaf in #5539 - [
isort
] Support globbing inisort
options by @tjkuson in #5473
Bug Fixes
- Support autofix for some multiline
str.format
calls by @harupy in #5638 - Avoid triggering
unnecessary-map
(C417
) for late-bound lambdas by @charliermarsh in #5520 - Avoid triggering DTZ001-006 when using
.astimezone()
by @dhruvmanila in #5524 - Enable attribute lookups via semantic model by @charliermarsh in #5536
- Avoid syntax errors when rewriting str(dict) in f-strings by @charliermarsh in #5538
- Differentiate between runtime and typing-time annotations by @charliermarsh in #5575
- Only run pyproject.toml lint rules when enabled by @charliermarsh in #5578
- Refactor isort directive skips to use iterators by @charliermarsh in #5623
- Allow descriptor instantiations in dataclass fields by @charliermarsh in #5537
- Refactor
noqa
directive parsing away from regex-based implementation by @charliermarsh in #5554 - Emit warnings for invalid
# noqa
directives by @charliermarsh in #5571 - Support individual codes on
# flake8: noqa
directives by @charliermarsh in #5618 - Add
tkinter
import convention by @tjkuson in #5626 - Avoid
PERF401
if conditional depends on list var by @dhruvmanila in #5603 - Fix typo in complex-if-statement-in-stub message by @charliermarsh in #5635
- Make TRY301 trigger only if a
raise
throws a caught exception by @evanrittenhouse in #5455 - Skip flake8-future-annotations checks in stub files by @charliermarsh in #5652
- Always allow PEP 585 and PEP 604 rewrites in stub files by @charliermarsh in #5653
- Add support for
Union
declarations without|
to PYI016 by @zanieb in #5598 - Ignore
_name_
and_value_
accesses inflake8-self
rules by @monosans in #5663 - Refactor
repeated_keys()
to useComparableExpr
by @qdegraaf in #5696
New Contributors
- @karosis88 made their first contribution in #5560
- @petermattia made their first contribution in #5579
- @DimitriPapadopoulos made their first contribution in #5607
Full Changelog: v0.0.277...v0.0.278