-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Issue detect useless generator pattern #520
Issue detect useless generator pattern #520
Conversation
@@ -199,6 +200,21 @@ def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]: | |||
type(self), | |||
) | |||
|
|||
elif ( | |||
node.func.id == "sorted" |
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.
From the original issue:
the (a for a in b) generator construct doesn't seem particularly useful and just adds an unnecessary context switch of the generator.
I think we can check every generator, not only those inside sorted call.
This mean that the check would be only the isinstance
of node as ast.GeneratorExp
and isinstance
of node.elt
as ast.Name
. What do you think?
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.
You should be right.
We should verify if the Generator do something, in all cases, not only for sorted call.
I need to put this on my desktop : KISS 👍
Closing because it seems work has stalled. Feel free to reopen if you continue work. |
In progress