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

# Collection Into Set

#### Sourcery refactoring id: `collection-into-set`

#### Description:

Use set when checking membership of a collection of literals

#### Before:

```python
if currency in ["EUR", "USD"]:
    take_payment()
```

#### After:

```python
if currency in {"EUR", "USD"}:
    take_payment()
```

#### Explanation:

When checking if a variable is one of a collection of literals it is both more
natural and more performant to use a `set` rather than a `list` or `tuple` to
define that collection. Note that this can only be done where Sourcery can
ascertain that the value being checked is of a hashable type.
