MartinThoma / flake8-simplify

❄ A flake8 plugin that helps you to simplify code
MIT License
186 stars 19 forks source link

SIM104: Remove false-positives in case the loop is not a direct child of an async function #147

Closed wyuenho closed 2 years ago

wyuenho commented 2 years ago

Not all for loops within a function body is a direct child of the function body

Closes #146

MartinThoma commented 2 years ago

Thank you for the PR! The idea is good, but I think you need to add a check on the parent. Maybe you can check isinstance(parent, typing.Callable) to avoid getting up to module level?

wyuenho commented 2 years ago

isinstance(parent, typing.Callable)

I'm very confused by this comment lol, wut?

BTW, I've fixed the tests, and added one extra.

MartinThoma commented 2 years ago

Thank you very much :hugs: I'll make a release in a few minutes