Page MenuHomePhabricator

[lint] address new errors introduced by flake8-comprehensions 3.12.0
ClosedPublic

Authored by PiRK on Apr 27 2023, 15:02.

Details

Summary

From the doc:

C419 Unnecessary list comprehension in <any/all>() prevents short-circuiting - rewrite as a generator.

Using a list comprehension inside a call to any()/all() prevents short-circuiting when a True / False value is found. The whole list will be constructed before calling any()/all(), potentially wasting work. Rewrite to use a generator expression, which can stop part way.

Another new error code C418 (dict({}) --> {}) is also introduced, but we don't have any instance of it in the codebase.

Test Plan
pip install flake8-comprehensions --upgrade
flake8 . | grep C41[89]
cd build && ninja check-functional-extended

Diff Detail

Event Timeline

PiRK requested review of this revision.Apr 27 2023, 15:02

revert some isort changes (build was incorrectly detected as a non-local module)

This revision is now accepted and ready to land.Apr 27 2023, 17:14