> ## 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.

# Simplify Generator

#### Sourcery refactoring id: `simplify-generator`

#### Description:

An identity generator `(a for a in coll)` can be replaced directly with the
collection `coll`

#### Before:

```python
if any(hat for hat in wardrobe.hats):
    print("I have a hat!")
```

#### After:

```python
if any(wardrobe.hats):
    print("I have a hat!")
```

#### Explanation:

The expression `(x for x in y)` is a generator that returns all of the elements
of y. If being passed into a function like `any` or `all` that takes a generator
or sequence, it can simply be replaced by `y` which is much clearer.
