COALESCE_BRACKETS might only coalesce first set when logical operators used
- Dominant language
- Python
- Stars
- 14k
- Forks
- 904
- PR merge metrics
- No merged PRs in 30d
Description
## Good behaviour example
```python
call_func_that_takes_a_dict(
{
'key1': 'value1',
'key2': 'value2',
} + {
'key3': 'value3',
'key4': 'value4',
}
)
```
With `coalesce_brackets`:
```python
call_func_that_takes_a_dict({
'key1': 'value1',
'key2': 'value2',
} + {
'key3': 'value3',
'key4': 'value4',
})
```
This formats as expected.
## Bad behaviour example
```python
check_ips = '|'.join(
[v['ip'] for v in config['agents']['hypervisors'].values()] +
[v['ip'] for v in config['master']['hypervisors'].values()]
)
```
With `coalesce_brackets`:
```python
check_ips = '|'.join([
v['ip'] for v in config['agents']['hypervisors'].values()
] + [v['ip'] for v in config['master']['hypervisors'].values()])
```
Expected either:
* Original (we shouldn't coalesce when more than one set of brackets exists upon an operator), or
* Both bracket sets are formatted appropriately to ensure `dedent_closing_brackets` honoured (when the entire set, not the individual list, cannot fit on a single line), ie.
```python
check_ips = '|'.join([
v['ip'] for v in config['agents']['hypervisors'].values()
] + [
v['ip'] for v in config['master']['hypervisors'].values()
])
```
Contributor guide
Assessment
This issue has not been assessed yet.