> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Convert Any to In

#### Sourcery refactoring id: `convert-any-to-in`

#### Description:

Converts `any()` functions to simpler `in` statements

#### Before:

```python
def shout_about_bowlers(hats: list[str]) -> None:
    if any(hat == "bowler" for hat in hats):
        shout("I have a bowler hat!")
```

#### After:

```python
def shout_about_bowlers(hats: list[str]) -> None:
    if "bowler" in hats:
        shout("I have a bowler hat!")
```

#### Explanation:

Using Python's `in` operator simplifies the code and makes it much easier to
tell at a glance that you are checking if something is present in the sequence.

Note that this only triggers if we can detect that the collection being iterated
over is not a string type - in this case the semantics of the before/after code
would be different.
