Convert Any to In

Python pattern

Converts any() functions to simpler in statements.


Apply with the Grit CLI
grit apply any_to_in

Convert any to in

BEFORE
if any(hat == "bowler" for hat in hats):
    shout("I have a bowler hat!")

if any(hat > "bowler" for hat in hats):
    shout("I have a bowler hat!")
AFTER
if "bowler" in hats:
    shout("I have a bowler hat!")

if any(hat > "bowler" for hat in hats):
    shout("I have a bowler hat!")