google / google/yapf

DEDENT_CLOSING_BRACKETS has odd split behaviour if arguments fit in line, but expression does not

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

Description

Might be similar behaviour issues to #349, but regardless, the following snippet:
```python
record['data'] = {
data['data_key']: data['data_value']
for data in self.get_resource(
'service_instance_data',
svc_id=record['svc_id']
)
}
```

When formatting based on PEP8 style, the arguments are condensed to a single line:
```python
record['data'] = {
data['data_key']: data['data_value']
for data in self.get_resource(
'service_instance_data', svc_id=record['svc_id'])
}
```
When applying `DEDENT_CLOSING_BRACKETS`, I would expect the original code to pass (due to argument line split, but instead it splits after `self`, trying to fit the expression:
```python
record['data'] = {
data['data_key']: data['data_value']
for data in self.
get_resource('service_instance_data', svc_id=record['svc_id'])
}
```

This happens regardless of the PEP8 or original code being submitted for formatting.

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.