google / google/yapf

knob for avoiding splitting of tuples?

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

Description

I tried fiddling with `split_penalty_after_opening_bracket` and `split_penalty_for_added_line_split` ... the following values mostly do what I like:

```
split_penalty_after_opening_bracket=-100
split_penalty_for_added_line_split=300
```
and produce nice changes like this:
```python
-def json_ordinal_edge(source: Vname, edge_name: str, ordinal: int,
- target: Vname) -> Text:
+def json_ordinal_edge(
+ source: Vname, edge_name: str, ordinal: int, target: Vname) -> Text:
```
```python
- yield from kythe_facts.add_variable(self.fqn, fqn_vname, b'record',
- b'class')
+ yield from kythe_facts.add_variable(
+ self.fqn, fqn_vname, b'record', b'class')
```
```python
- return '{}'.format(html_class,
- _expand_to_html(text))
+ return '{}'.format(
+ html_class, _expand_to_html(text))
```
```python
- op_astns = xcast(ast_cooked.OpNode, cvt(node.children[i],
- ctx)).op_astns
- typing_debug.assert_all_isinstance(pytree.Leaf,
- op_astns) # TODO: remove
+ op_astns = xcast(ast_cooked.OpNode, cvt(
+ node.children[i], ctx)).op_astns
+ typing_debug.assert_all_isinstance(
+ pytree.Leaf, op_astns) # TODO: remove
```

But I don't like this ... any suggestions for fixing it?
```python
yield json_fact_from_dict(
source_vname, 'x-class',
- collections.OrderedDict(
- [('class', self.fqn),
- ('bases', [base.as_json_dict() for base in self.bases])]))
+ collections.OrderedDict([('class', self.fqn), ('bases', [
+ base.as_json_dict() for base in self.bases
+ ])]))
```

The following are also side effects of the changes I made to the two parameter, which I'm neutral about:
```python
- return collections.OrderedDict(
- (k, getattr(self, k)) for k in self.__slots__)
+ return collections.OrderedDict((k, getattr(self, k))
+ for k in self.__slots__)
```
```python
- def anchors(self, ctx: FqnCtx,
- anchors: List[kythe.Anchor]) -> ast_fqn.Base:
+ def anchors(
+ self, ctx: FqnCtx, anchors: List[kythe.Anchor]) -> ast_fqn.Base:
```
```python
- def __init__(self, *, astn: pytree.Base, for_exprlist: Base,
- in_testlist: Base, comp_iter: Base,
- scope_bindings: Dict[Text, None]) -> None:
+ def __init__(
+ self, *, astn: pytree.Base, for_exprlist: Base, in_testlist: Base,
+ comp_iter: Base, scope_bindings: Dict[Text, None]) -> None:
```
```python
- ctx.bindings.update(
- (name, ctx.fqn_dot + name) for name in self.scope_bindings)
+ ctx.bindings.update((name, ctx.fqn_dot + name)
+ for name in self.scope_bindings)
```

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.