mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00

## Summary This adds an autofix for PIE800 (unnecessary spread) -- whenever we see a `**{...}` inside another dictionary literal, just delete the `**{` and `}` to inline the key-value pairs. So `{"a": "b", **{"c": "d"}}` becomes just `{"a": "b", "c": "d"}`. I have enabled this just for preview mode. ## Test Plan Updated the preview snapshot test.
29 lines
519 B
Python
29 lines
519 B
Python
{"foo": 1, **{"bar": 1}} # PIE800
|
|
|
|
{**{"bar": 10}, "a": "b"} # PIE800
|
|
|
|
foo({**foo, **{"bar": True}}) # PIE800
|
|
|
|
{**foo, **{"bar": 10}} # PIE800
|
|
|
|
{ # PIE800
|
|
"a": "b",
|
|
# Preserve
|
|
**{
|
|
# all
|
|
"bar": 10, # the
|
|
# comments
|
|
},
|
|
}
|
|
|
|
{**foo, **buzz, **{bar: 10}} # PIE800
|
|
|
|
{**foo, "bar": True } # OK
|
|
|
|
{"foo": 1, "buzz": {"bar": 1}} # OK
|
|
|
|
{**foo, "bar": True } # OK
|
|
|
|
Table.objects.filter(inst=inst, **{f"foo__{bar}__exists": True}) # OK
|
|
|
|
buzz = {**foo, "bar": { 1: 2 }} # OK
|