-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Enhancement ✨Improvement to a componentImprovement to a componentGood first issueFriendly and approachable by new contributorsFriendly and approachable by new contributorsHacktoberfestHelp wanted 🙏Outside help would be appreciated, good for new contributorsOutside help would be appreciated, good for new contributors
Milestone
Description
Current problem
Here is a function from Astroid:
def is_from_decorator(node):
"""Return True if the given node is the child of a decorator"""
for parent in node.node_ancestors():
if isinstance(parent, Decorators):
return True
return FalseWhat does it do? Evidently it loops over the node's ancestors and returns whether any of them are decorators. Well, why not just say that?
def is_from_decorator(node):
"""Return True if the given node is the child of a decorator"""
return any(isinstance(parent, Decorators)
for parent in node.node_ancestors())Desired solution
The any and all functions are generally shorter and more declarative than explicit looping, so add a check to suggest using them when appropriate.
Implmenting this check so as to avoid too many false positives might be an interesting challenge!
Additional context
No response
Metadata
Metadata
Assignees
Labels
Enhancement ✨Improvement to a componentImprovement to a componentGood first issueFriendly and approachable by new contributorsFriendly and approachable by new contributorsHacktoberfestHelp wanted 🙏Outside help would be appreciated, good for new contributorsOutside help would be appreciated, good for new contributors