google / google/yapf

yapf gets confused when a dict literal has lambdas as values

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

Description

Input:
```
{
'a': lambda a, b: True,
'b': lambda c, d: False,
}
```

yapf wants to apply this diff:

```
--- narf.py (original)
+++ narf.py (reformatted)
@@ -1,4 +1,6 @@
{
- 'a': lambda a, b: True,
- 'b': lambda c, d: False,
+ 'a': lambda a,
+ b: True,
+ 'b': lambda c,
+ d: False,
}
```

IOW

```
{
'a': lambda a,
b: True,
'b': lambda c,
d: False,
}
```

Which strikes me as awful. This is with `allow_multiline_lambdas = true` in case that matters. Noticed on the hg codebase, where we're considering using yapf.

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.