-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve whitespace around ListComp
brackets in C419
#4099
Preserve whitespace around ListComp
brackets in C419
#4099
Conversation
b095027
to
1ceb40b
Compare
Hmm, wait this doesn't look correct (missing the initial insta snapshot). |
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
Context:
This seems a bit difficult but here are some of my ideas:
/cc @charliermarsh @MichaReiser your input would be appreciated :) |
I've read this a few times and keep finding myself undecided. I think adding extra parentheses is undesirable, so I'm leaning towards Option 2. What I don't fully understand is the role on the comma in that logic -- how does it differ when the comment is present vs. absent? |
Ok, so the all(
[x.id for x in bar], # comment
)
# vs
all(
[x.id for x in bar]
) The issue we're facing is that the comment is in the |
I'm unfamiliar with LibCST, and I've failed to find a clear definition of how libCST decides to attach trivia (to which node/property). So what I'm saying here may not make sense in the context of LibCST. I prefer your second option, and you're algorithm for copying the trivia makes sense to me. Do we need some logic for copying any trivia attached to the opening bracket too? What if it is a standalone comprehension or will this never trigger C419? [
i for i in range(10) # comment
] |
I believe we should but I don't see any use case for having a comment on the opening bracket (correct me if I'm wrong): any(
[ # where would this comment be used?
i.id for i in range(5)
]
)
# If so, that should be converted to
any(
i.id for i in range(5) # where would this comment be used?
) In case we want to support it, I believe it should be added or appended to the generator expression node as shown above. And, in the worst case, if there are comments in all three places: any(
[ # rbracket comment
i.id for i in range(5) # comprehension comment
] # lbracket comment
)
any(
i.id for i in range(5) # comprehension comment # lbracket comment # rbracket comment
) One more thing to note is that any(
[
i.id for i in range(5) # comprehension comment
] # lbracket comment
)
any([i.id for i in range(5)]) # comprehension comment # lbracket comment
This won't be triggered for standalone comprehensions. The rule is only for |
My take is that ruff should never remove any comments and we can either not provide a fix in that case or implement the proper placement.
I would prefer writing the What do you think of attaching the # rbracket comment
i.id for i in range(5) # comprehension comment Are there any more edge cases, for example, when > any(
> # lbracket leading
> [ # lbracket trailing
> i.id for i in range(5) # comprehension comment
> # rbracket_leading
> ] # rbracket trailing
> ) Or is this not an issue because of how libCST represents comments? |
Um wait, I think I switched the So,
I agree on that. The problem is stemming from the fact that we're removing the tokens (left and right brackets) which means that whatever trivia belonged to that token is being removed as well.
My first thought was that order wouldn't matter as both would belong to the same line but I can understand your point of view.
Oh wait! This suggestion led me to another idea (thanks!): So, there's another node in any(
[ # lbracket comment
i.bit_count() for i in range(5) # rbracket comment
] # rpar comment
)
any(
# lbracket comment
i.bit_count() for i in range(5) # rbracket comment # rpar comment
)
What do you think?
This won't be an issue as those belong with the parenthesis which are copied correctly over to the generator expression (line 1162, 1163): |
Unfortunately we do remove comments in some situations. Ruff's comment-handling for autofixes is "best effort" right now. In some cases, with complex expressions, we do skip the autofix entirely if comments are present, but it's done on a case-by-case basis. |
@dhruvmanila I'm really impressed by how carefully and thoughtfully you exercise the comment placement! It's a joy to read your explanations.
I love it. That would match my expectations. I also thought about whether we want to keep the |
Thanks a lot for those kind words! I really appreciate it and also inspired by your detailed explanations :)
Got it. I'll try to finish this by tonight. |
b8319a2
to
93249ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent
.. | ||
}) = &list_comp.lbracket.whitespace_after | ||
{ | ||
// If there's a comment on the line after the opening bracket, we need |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love these comments! Thank you so much for taking the time to write them. It makes reviewing (and reading the code in the future) so much easier.
Doesn't need to block the merge here, but do we need to apply similar treatment to any of the other comprehension-transform rules? |
I had the same thought, let me check. In general wherever the parenthesis or brackets are being dropped, that's where this problem will occur. |
I've provided a few examples but there will be a few more. As mentioned that whenever the parenthesis or brackets are being dropped, that's where this will happen. It seems to be happening in most of comprehension fixes. I believe we should have a generalized way of resolving this. C404dict(
# first comment
[
# second comment
(i, i)
for i in range(3)
]
)
{
# first comment
i: i
for i in range(3)
} C405set(
# some comment
(1, 2)
)
{1, 2} C406dict(
# first comment
[
# second comment
(1, 2)
]
)
{
# first comment
1: 2
} C409tuple(
# some comment
[1, 2, 3, 4]
)
(1, 2, 3, 4) C410list(
# some comment
[1, 2, 3, 4]
)
[1, 2, 3, 4] C411list(
# comment
[i * i for i in x]
)
[i * i for i in x] |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) ([changelog](https://togithub.com/charliermarsh/ruff/releases)) | `^0.0.265` -> `^0.0.267` | [![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/compatibility-slim/0.0.265)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/confidence-slim/0.0.265)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.267`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.267) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.266...v0.0.267) <!-- Release notes generated using configuration in .github/release.yml at main --> #### Summary Follow-up release to v0.0.266 to fix an issue with `python -m ruff`- and `import ruff`-based workflows. (No new rules or functionality.) #### What's Changed ##### Rules - Implement `RUF010` to detect explicit type conversions within f-strings by [@​LotemAm](https://togithub.com/LotemAm) in [https://github.com/charliermarsh/ruff/pull/4387](https://togithub.com/charliermarsh/ruff/pull/4387) ##### Other Changes - Workaround for maturin bug by [@​konstin](https://togithub.com/konstin) in [https://github.com/charliermarsh/ruff/pull/4399](https://togithub.com/charliermarsh/ruff/pull/4399) #### New Contributors - [@​OMEGARAZER](https://togithub.com/OMEGARAZER) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3938](https://togithub.com/charliermarsh/ruff/pull/3938) - [@​LotemAm](https://togithub.com/LotemAm) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4387](https://togithub.com/charliermarsh/ruff/pull/4387) **Full Changelog**: astral-sh/ruff@v0.0.266...v0.0.267 ### [`v0.0.266`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.266) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.265...v0.0.266) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Breaking Changes - Remove deprecated `update-check` setting by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4313](https://togithub.com/charliermarsh/ruff/pull/4313) - JSON Emitter: Use one indexed column numbers for edits by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4007](https://togithub.com/charliermarsh/ruff/pull/4007) ##### Rules - \[`pygrep-hooks`] Implement pygrep-hook's Mock-mistake diagnostic by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4366](https://togithub.com/charliermarsh/ruff/pull/4366) - \[`pylint`] Implement `nested-min-max` (`W3301`) by [@​mccullocht](https://togithub.com/mccullocht) in [https://github.com/charliermarsh/ruff/pull/4200](https://togithub.com/charliermarsh/ruff/pull/4200) - \[`flynt`] Implement Flynt static string join transform as FLY002 by [@​akx](https://togithub.com/akx) in [https://github.com/charliermarsh/ruff/pull/4196](https://togithub.com/charliermarsh/ruff/pull/4196) - \[`pylint`] Include positional- and keyword-only arguments in too-many-arguments by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4329](https://togithub.com/charliermarsh/ruff/pull/4329) - \[`ruff`] Update confusable character mapping by [@​akx](https://togithub.com/akx) in [https://github.com/charliermarsh/ruff/pull/4274](https://togithub.com/charliermarsh/ruff/pull/4274) ##### Settings - Add .git-rewrite folder to default ignored folder paths by [@​jleclanche](https://togithub.com/jleclanche) in [https://github.com/charliermarsh/ruff/pull/4261](https://togithub.com/charliermarsh/ruff/pull/4261) - Feat: detect changes also in configuration files by [@​mikeleppane](https://togithub.com/mikeleppane) in [https://github.com/charliermarsh/ruff/pull/4169](https://togithub.com/charliermarsh/ruff/pull/4169) ##### Bug Fixes - Revert the B027 autofix logic by [@​aacunningham](https://togithub.com/aacunningham) in [https://github.com/charliermarsh/ruff/pull/4310](https://togithub.com/charliermarsh/ruff/pull/4310) - Consider Flask app logger as logger candidate by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4253](https://togithub.com/charliermarsh/ruff/pull/4253) - Enforce max-doc-length for multi-line docstrings by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4347](https://togithub.com/charliermarsh/ruff/pull/4347) - Avoid re-using imports beyond current edit site by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4378](https://togithub.com/charliermarsh/ruff/pull/4378) - Respect insertion location when importing symbols by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4258](https://togithub.com/charliermarsh/ruff/pull/4258) - Fix jemalloc page size on aarch64 by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4247](https://togithub.com/charliermarsh/ruff/pull/4247) - Fix replace_whitespace() tabulation to space by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/4226](https://togithub.com/charliermarsh/ruff/pull/4226) - Avoid fixing `PD002` in a lambda expression by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4286](https://togithub.com/charliermarsh/ruff/pull/4286) - Avoid `D403` if first char cannot be uppercased by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4283](https://togithub.com/charliermarsh/ruff/pull/4283) - Avoid panics for f-string rewrites at start-of-file by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4291](https://togithub.com/charliermarsh/ruff/pull/4291) - Rewrite `not not a` as `bool(a)` in boolean contexts by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4294](https://togithub.com/charliermarsh/ruff/pull/4294) - Include static and class methods in in abstract decorator list by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4298](https://togithub.com/charliermarsh/ruff/pull/4298) - Specify exact command in incorrect parentheses suggestion by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4300](https://togithub.com/charliermarsh/ruff/pull/4300) - Ignore `TRY301` exceptions without except handlers by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4301](https://togithub.com/charliermarsh/ruff/pull/4301) - Preserve whitespace around `ListComp` brackets in `C419` by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4099](https://togithub.com/charliermarsh/ruff/pull/4099) - Tweak capitalization of B021 message by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4350](https://togithub.com/charliermarsh/ruff/pull/4350) - Avoid debug panic with empty indent replacement by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4364](https://togithub.com/charliermarsh/ruff/pull/4364) - Use target name in hardcoded-password diagnostics by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4365](https://togithub.com/charliermarsh/ruff/pull/4365) - Avoid underflow in expected-special-method-signature by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4377](https://togithub.com/charliermarsh/ruff/pull/4377) - Respect `__all__` imports when determining definition visibility by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4357](https://togithub.com/charliermarsh/ruff/pull/4357) - Ignore some methods on list in `flake8-boolean-trap` by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4385](https://togithub.com/charliermarsh/ruff/pull/4385) - Fix false positives in PD002 by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/4337](https://togithub.com/charliermarsh/ruff/pull/4337) - Run autofix on initial watcher pass by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4311](https://togithub.com/charliermarsh/ruff/pull/4311) - Avoid SIM105 autofixes that would remove comments by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4330](https://togithub.com/charliermarsh/ruff/pull/4330) - Handle `.encode` calls on parenthesized expressions by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4338](https://togithub.com/charliermarsh/ruff/pull/4338) - Truncate `SyntaxError`s before newline character by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4124](https://togithub.com/charliermarsh/ruff/pull/4124) - Use non-empty ranges for logical-lines diagnostics by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4133](https://togithub.com/charliermarsh/ruff/pull/4133) #### New Contributors - [@​jleclanche](https://togithub.com/jleclanche) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4261](https://togithub.com/charliermarsh/ruff/pull/4261) - [@​aureliojargas](https://togithub.com/aureliojargas) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4306](https://togithub.com/charliermarsh/ruff/pull/4306) - [@​intgr](https://togithub.com/intgr) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4304](https://togithub.com/charliermarsh/ruff/pull/4304) - [@​mikeleppane](https://togithub.com/mikeleppane) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4169](https://togithub.com/charliermarsh/ruff/pull/4169) - [@​dependabot](https://togithub.com/dependabot) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4354](https://togithub.com/charliermarsh/ruff/pull/4354) **Full Changelog**: astral-sh/ruff@v0.0.265...v0.0.266 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43OS4xIiwidXBkYXRlZEluVmVyIjoiMzUuNzkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Signed-off-by: Renovate Bot <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) ([changelog](https://togithub.com/charliermarsh/ruff/releases)) | `==0.0.265` -> `==0.0.267` | [![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/compatibility-slim/0.0.265)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/confidence-slim/0.0.265)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.267`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.267) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.266...v0.0.267) <!-- Release notes generated using configuration in .github/release.yml at main --> #### Summary Follow-up release to v0.0.266 to fix an issue with `python -m ruff`- and `import ruff`-based workflows. (No new rules or functionality.) #### What's Changed ##### Rules - Implement `RUF010` to detect explicit type conversions within f-strings by [@​LotemAm](https://togithub.com/LotemAm) in [https://github.com/charliermarsh/ruff/pull/4387](https://togithub.com/charliermarsh/ruff/pull/4387) ##### Other Changes - Workaround for maturin bug by [@​konstin](https://togithub.com/konstin) in [https://github.com/charliermarsh/ruff/pull/4399](https://togithub.com/charliermarsh/ruff/pull/4399) #### New Contributors - [@​OMEGARAZER](https://togithub.com/OMEGARAZER) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3938](https://togithub.com/charliermarsh/ruff/pull/3938) - [@​LotemAm](https://togithub.com/LotemAm) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4387](https://togithub.com/charliermarsh/ruff/pull/4387) **Full Changelog**: astral-sh/ruff@v0.0.266...v0.0.267 ### [`v0.0.266`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.266) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.265...v0.0.266) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Breaking Changes - Remove deprecated `update-check` setting by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4313](https://togithub.com/charliermarsh/ruff/pull/4313) - JSON Emitter: Use one indexed column numbers for edits by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4007](https://togithub.com/charliermarsh/ruff/pull/4007) ##### Rules - \[`pygrep-hooks`] Implement pygrep-hook's Mock-mistake diagnostic by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4366](https://togithub.com/charliermarsh/ruff/pull/4366) - \[`pylint`] Implement `nested-min-max` (`W3301`) by [@​mccullocht](https://togithub.com/mccullocht) in [https://github.com/charliermarsh/ruff/pull/4200](https://togithub.com/charliermarsh/ruff/pull/4200) - \[`flynt`] Implement Flynt static string join transform as FLY002 by [@​akx](https://togithub.com/akx) in [https://github.com/charliermarsh/ruff/pull/4196](https://togithub.com/charliermarsh/ruff/pull/4196) - \[`pylint`] Include positional- and keyword-only arguments in too-many-arguments by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4329](https://togithub.com/charliermarsh/ruff/pull/4329) - \[`ruff`] Update confusable character mapping by [@​akx](https://togithub.com/akx) in [https://github.com/charliermarsh/ruff/pull/4274](https://togithub.com/charliermarsh/ruff/pull/4274) ##### Settings - Add .git-rewrite folder to default ignored folder paths by [@​jleclanche](https://togithub.com/jleclanche) in [https://github.com/charliermarsh/ruff/pull/4261](https://togithub.com/charliermarsh/ruff/pull/4261) - Feat: detect changes also in configuration files by [@​mikeleppane](https://togithub.com/mikeleppane) in [https://github.com/charliermarsh/ruff/pull/4169](https://togithub.com/charliermarsh/ruff/pull/4169) ##### Bug Fixes - Revert the B027 autofix logic by [@​aacunningham](https://togithub.com/aacunningham) in [https://github.com/charliermarsh/ruff/pull/4310](https://togithub.com/charliermarsh/ruff/pull/4310) - Consider Flask app logger as logger candidate by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4253](https://togithub.com/charliermarsh/ruff/pull/4253) - Enforce max-doc-length for multi-line docstrings by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4347](https://togithub.com/charliermarsh/ruff/pull/4347) - Avoid re-using imports beyond current edit site by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4378](https://togithub.com/charliermarsh/ruff/pull/4378) - Respect insertion location when importing symbols by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4258](https://togithub.com/charliermarsh/ruff/pull/4258) - Fix jemalloc page size on aarch64 by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4247](https://togithub.com/charliermarsh/ruff/pull/4247) - Fix replace_whitespace() tabulation to space by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/4226](https://togithub.com/charliermarsh/ruff/pull/4226) - Avoid fixing `PD002` in a lambda expression by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4286](https://togithub.com/charliermarsh/ruff/pull/4286) - Avoid `D403` if first char cannot be uppercased by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4283](https://togithub.com/charliermarsh/ruff/pull/4283) - Avoid panics for f-string rewrites at start-of-file by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4291](https://togithub.com/charliermarsh/ruff/pull/4291) - Rewrite `not not a` as `bool(a)` in boolean contexts by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4294](https://togithub.com/charliermarsh/ruff/pull/4294) - Include static and class methods in in abstract decorator list by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4298](https://togithub.com/charliermarsh/ruff/pull/4298) - Specify exact command in incorrect parentheses suggestion by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4300](https://togithub.com/charliermarsh/ruff/pull/4300) - Ignore `TRY301` exceptions without except handlers by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4301](https://togithub.com/charliermarsh/ruff/pull/4301) - Preserve whitespace around `ListComp` brackets in `C419` by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4099](https://togithub.com/charliermarsh/ruff/pull/4099) - Tweak capitalization of B021 message by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4350](https://togithub.com/charliermarsh/ruff/pull/4350) - Avoid debug panic with empty indent replacement by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4364](https://togithub.com/charliermarsh/ruff/pull/4364) - Use target name in hardcoded-password diagnostics by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4365](https://togithub.com/charliermarsh/ruff/pull/4365) - Avoid underflow in expected-special-method-signature by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4377](https://togithub.com/charliermarsh/ruff/pull/4377) - Respect `__all__` imports when determining definition visibility by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4357](https://togithub.com/charliermarsh/ruff/pull/4357) - Ignore some methods on list in `flake8-boolean-trap` by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4385](https://togithub.com/charliermarsh/ruff/pull/4385) - Fix false positives in PD002 by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/4337](https://togithub.com/charliermarsh/ruff/pull/4337) - Run autofix on initial watcher pass by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4311](https://togithub.com/charliermarsh/ruff/pull/4311) - Avoid SIM105 autofixes that would remove comments by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4330](https://togithub.com/charliermarsh/ruff/pull/4330) - Handle `.encode` calls on parenthesized expressions by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4338](https://togithub.com/charliermarsh/ruff/pull/4338) - Truncate `SyntaxError`s before newline character by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4124](https://togithub.com/charliermarsh/ruff/pull/4124) - Use non-empty ranges for logical-lines diagnostics by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4133](https://togithub.com/charliermarsh/ruff/pull/4133) #### New Contributors - [@​jleclanche](https://togithub.com/jleclanche) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4261](https://togithub.com/charliermarsh/ruff/pull/4261) - [@​aureliojargas](https://togithub.com/aureliojargas) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4306](https://togithub.com/charliermarsh/ruff/pull/4306) - [@​intgr](https://togithub.com/intgr) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4304](https://togithub.com/charliermarsh/ruff/pull/4304) - [@​mikeleppane](https://togithub.com/mikeleppane) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4169](https://togithub.com/charliermarsh/ruff/pull/4169) - [@​dependabot](https://togithub.com/dependabot) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4354](https://togithub.com/charliermarsh/ruff/pull/4354) **Full Changelog**: astral-sh/ruff@v0.0.265...v0.0.266 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/flux-local). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43OS4xIiwidXBkYXRlZEluVmVyIjoiMzUuNzkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) ([changelog](https://togithub.com/charliermarsh/ruff/releases)) | `==0.0.265` -> `==0.0.267` | [![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/compatibility-slim/0.0.265)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.267/confidence-slim/0.0.265)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.267`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.267) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.266...v0.0.267) <!-- Release notes generated using configuration in .github/release.yml at main --> #### Summary Follow-up release to v0.0.266 to fix an issue with `python -m ruff`- and `import ruff`-based workflows. (No new rules or functionality.) #### What's Changed ##### Rules - Implement `RUF010` to detect explicit type conversions within f-strings by [@​LotemAm](https://togithub.com/LotemAm) in [https://github.com/charliermarsh/ruff/pull/4387](https://togithub.com/charliermarsh/ruff/pull/4387) ##### Other Changes - Workaround for maturin bug by [@​konstin](https://togithub.com/konstin) in [https://github.com/charliermarsh/ruff/pull/4399](https://togithub.com/charliermarsh/ruff/pull/4399) #### New Contributors - [@​OMEGARAZER](https://togithub.com/OMEGARAZER) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3938](https://togithub.com/charliermarsh/ruff/pull/3938) - [@​LotemAm](https://togithub.com/LotemAm) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4387](https://togithub.com/charliermarsh/ruff/pull/4387) **Full Changelog**: astral-sh/ruff@v0.0.266...v0.0.267 ### [`v0.0.266`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.266) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.265...v0.0.266) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Breaking Changes - Remove deprecated `update-check` setting by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4313](https://togithub.com/charliermarsh/ruff/pull/4313) - JSON Emitter: Use one indexed column numbers for edits by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4007](https://togithub.com/charliermarsh/ruff/pull/4007) ##### Rules - \[`pygrep-hooks`] Implement pygrep-hook's Mock-mistake diagnostic by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4366](https://togithub.com/charliermarsh/ruff/pull/4366) - \[`pylint`] Implement `nested-min-max` (`W3301`) by [@​mccullocht](https://togithub.com/mccullocht) in [https://github.com/charliermarsh/ruff/pull/4200](https://togithub.com/charliermarsh/ruff/pull/4200) - \[`flynt`] Implement Flynt static string join transform as FLY002 by [@​akx](https://togithub.com/akx) in [https://github.com/charliermarsh/ruff/pull/4196](https://togithub.com/charliermarsh/ruff/pull/4196) - \[`pylint`] Include positional- and keyword-only arguments in too-many-arguments by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4329](https://togithub.com/charliermarsh/ruff/pull/4329) - \[`ruff`] Update confusable character mapping by [@​akx](https://togithub.com/akx) in [https://github.com/charliermarsh/ruff/pull/4274](https://togithub.com/charliermarsh/ruff/pull/4274) ##### Settings - Add .git-rewrite folder to default ignored folder paths by [@​jleclanche](https://togithub.com/jleclanche) in [https://github.com/charliermarsh/ruff/pull/4261](https://togithub.com/charliermarsh/ruff/pull/4261) - Feat: detect changes also in configuration files by [@​mikeleppane](https://togithub.com/mikeleppane) in [https://github.com/charliermarsh/ruff/pull/4169](https://togithub.com/charliermarsh/ruff/pull/4169) ##### Bug Fixes - Revert the B027 autofix logic by [@​aacunningham](https://togithub.com/aacunningham) in [https://github.com/charliermarsh/ruff/pull/4310](https://togithub.com/charliermarsh/ruff/pull/4310) - Consider Flask app logger as logger candidate by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4253](https://togithub.com/charliermarsh/ruff/pull/4253) - Enforce max-doc-length for multi-line docstrings by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4347](https://togithub.com/charliermarsh/ruff/pull/4347) - Avoid re-using imports beyond current edit site by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4378](https://togithub.com/charliermarsh/ruff/pull/4378) - Respect insertion location when importing symbols by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4258](https://togithub.com/charliermarsh/ruff/pull/4258) - Fix jemalloc page size on aarch64 by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4247](https://togithub.com/charliermarsh/ruff/pull/4247) - Fix replace_whitespace() tabulation to space by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/4226](https://togithub.com/charliermarsh/ruff/pull/4226) - Avoid fixing `PD002` in a lambda expression by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4286](https://togithub.com/charliermarsh/ruff/pull/4286) - Avoid `D403` if first char cannot be uppercased by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4283](https://togithub.com/charliermarsh/ruff/pull/4283) - Avoid panics for f-string rewrites at start-of-file by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4291](https://togithub.com/charliermarsh/ruff/pull/4291) - Rewrite `not not a` as `bool(a)` in boolean contexts by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4294](https://togithub.com/charliermarsh/ruff/pull/4294) - Include static and class methods in in abstract decorator list by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4298](https://togithub.com/charliermarsh/ruff/pull/4298) - Specify exact command in incorrect parentheses suggestion by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4300](https://togithub.com/charliermarsh/ruff/pull/4300) - Ignore `TRY301` exceptions without except handlers by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4301](https://togithub.com/charliermarsh/ruff/pull/4301) - Preserve whitespace around `ListComp` brackets in `C419` by [@​dhruvmanila](https://togithub.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4099](https://togithub.com/charliermarsh/ruff/pull/4099) - Tweak capitalization of B021 message by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4350](https://togithub.com/charliermarsh/ruff/pull/4350) - Avoid debug panic with empty indent replacement by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4364](https://togithub.com/charliermarsh/ruff/pull/4364) - Use target name in hardcoded-password diagnostics by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4365](https://togithub.com/charliermarsh/ruff/pull/4365) - Avoid underflow in expected-special-method-signature by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4377](https://togithub.com/charliermarsh/ruff/pull/4377) - Respect `__all__` imports when determining definition visibility by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4357](https://togithub.com/charliermarsh/ruff/pull/4357) - Ignore some methods on list in `flake8-boolean-trap` by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4385](https://togithub.com/charliermarsh/ruff/pull/4385) - Fix false positives in PD002 by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/4337](https://togithub.com/charliermarsh/ruff/pull/4337) - Run autofix on initial watcher pass by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4311](https://togithub.com/charliermarsh/ruff/pull/4311) - Avoid SIM105 autofixes that would remove comments by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4330](https://togithub.com/charliermarsh/ruff/pull/4330) - Handle `.encode` calls on parenthesized expressions by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4338](https://togithub.com/charliermarsh/ruff/pull/4338) - Truncate `SyntaxError`s before newline character by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4124](https://togithub.com/charliermarsh/ruff/pull/4124) - Use non-empty ranges for logical-lines diagnostics by [@​MichaReiser](https://togithub.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4133](https://togithub.com/charliermarsh/ruff/pull/4133) #### New Contributors - [@​jleclanche](https://togithub.com/jleclanche) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4261](https://togithub.com/charliermarsh/ruff/pull/4261) - [@​aureliojargas](https://togithub.com/aureliojargas) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4306](https://togithub.com/charliermarsh/ruff/pull/4306) - [@​intgr](https://togithub.com/intgr) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4304](https://togithub.com/charliermarsh/ruff/pull/4304) - [@​mikeleppane](https://togithub.com/mikeleppane) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4169](https://togithub.com/charliermarsh/ruff/pull/4169) - [@​dependabot](https://togithub.com/dependabot) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4354](https://togithub.com/charliermarsh/ruff/pull/4354) **Full Changelog**: astral-sh/ruff@v0.0.265...v0.0.266 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/pyrainbird). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43OS4xIiwidXBkYXRlZEluVmVyIjoiMzUuNzkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Summary
While converting from a list comprehension to a generator expression, the square brackets are not preserved as that are only present on a list comprehension.
We'll convert the brackets into a paren node and add it at the end and start of the left and right parens respectively.
fixes: #4094