google / google/yapf

introduce a configure dot split penalty

Open
#804 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
14k
Forks
904
PR merge metrics
No merged PRs in 30d

Description

Given this file:

```python
l = {
'foo': {
'bar':
re.compile(r'lllllllllllllllllllllllllllllllllllloooooooooooooooooooooooolllllllllllllllllllllllllllllllllllll'),
}
}
```

## Config 1

```ini
[style]
based_on_style = pep8
column_limit = 80
dedent_closing_brackets = true
```

Output is fine:

```python
l = {
'foo': {
'bar':
re.compile(
r'lllllllllllllllllllllllllllllllllllloooooooooooooooooooooooolllllllllllllllllllllllllllllllllllll'
),
}
}
```

## Config 2

```ini
[style]
based_on_style = pep8
column_limit = 120
dedent_closing_brackets = true
```

Output is uglier:

```
l = {
'foo': {
'bar':
re.
compile(r'lllllllllllllllllllllllllllllllllllloooooooooooooooooooooooolllllllllllllllllllllllllllllllllllll'),
}
}
```

The first output would have been prettier: having the string alone, rather than splitting before a dot. Maybe adding a configurable penalty for dot splitting would help? Or just output the first directly?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.