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

# Hoist If from If

#### Sourcery refactoring id: `hoist-if-from-if`

#### Description:

Moves `if` statements that match a conditional out of that conditional

#### Before:

```python
if hat.quality < DESIRED_QUALITY:
    happiness -= 1
    if not hat.is_stylish() and hat.quality < DESIRED_QUALITY:
        happiness -= 1
```

#### After:

```python
if hat.quality < DESIRED_QUALITY:
    happiness -= 1
if not hat.is_stylish() and hat.quality < DESIRED_QUALITY:
    happiness -= 1
```

#### Explanation:

Where a nested conditional repeats the conditions of the outer one, it is
logically equivalent to reduce the level of nesting as shown above. Doing this
can make the meaning of the code slightly clearer.
