-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[perflint] Parenthesize generator expressions (PERF401)
#19325
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
Conversation
|
ntBre
left a comment
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.
Thanks! This looks good, just one suggestion to avoid allocating a second string.
crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
|
Done as said |
|
Does this add extra parentheses if the generator expression is already parenthesized? |
|
I think it will, but I don't think it will affect the result. I have tested it |
That's a good point. Can we add a test case demonstrating this behavior? I think we should be able to use ruff/crates/ruff_python_ast/src/parenthesize.rs Lines 58 to 61 in d81ba58
|
|
Sure we can and i am adding it! |
ntBre
left a comment
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.
Thanks! Just one more minor simplification suggestion.
crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
perflint] Parenthesize generator expressions (PERF401)perflint] Parenthesize generator expressions (PERF401)
* main: [ty] Fix narrowing and reachability of class patterns with arguments (#19512) [ty] Implemented partial support for "find references" language server feature. (#19475) [`flake8-use-pathlib`] Add autofix for `PTH101`, `PTH104`, `PTH105`, `PTH121` (#19404) [`perflint`] Parenthesize generator expressions (`PERF401`) (#19325) [`pep8-naming`] Fix `N802` false positives for `CGIHTTPRequestHandler` and `SimpleHTTPRequestHandler` (#19432) [`pylint`] Handle empty comments after line continuation (`PLR2044`) (#19405) Move concise diagnostic rendering to `ruff_db` (#19398) [ty] highlight the argument in `static_assert` error messages (#19426) [ty] Infer single-valuedness for enums based on `int`/`str` (#19510) [ty] Restructure submodule query around `File` dependency [ty] Make `Module` a Salsa ingredient [ty] Reachability analysis for `isinstance(…)` branches (#19503) [ty] Normalize single-member enums to their instance type (#19502) [ty] Invert `ty_ide` and `ty_project` dependency (#19501) [ty] Implement mock language server for testing (#19391) [ty] Detect enums if metaclass is a subtype of EnumType/EnumMeta (#19481) [ty] perform type narrowing for places marked `global` too (#19381)
## Summary closes #19204 ## Test Plan 1. test case is added in dedicated file 2. locally tested the code manually --------- Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com> Co-authored-by: CodeMan62 <sharmahimanshu150082007@gmail.com>
Summary
closes #19204
Test Plan