google / google/yapf

A knob to make EACH_DICT_ENTRY_ON_SEPARATE_LINE recursive.

Open
#1,004 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

Consider the following:
```
- log({
- "type": "networking.cluster.node_sharing",
- "message": f"Sent our node-list to cluster node {self._nodes_by_fileno[fileno]}",
- "data": {
- "addr": self._sockets[fileno]['addr'][0],
- "port": self._sockets[fileno]['addr'][1],
- "fileno": fileno,
- "payload": data,
- "nodes": self._nodes
- }
- }, level=logging.INFO)

+ log(
+ {
+ "type": "networking.cluster.node_sharing",
+ "message": f"Sent our node-list to cluster node {self._nodes_by_fileno[fileno]}",
+ "data": {
+ "addr": self._sockets[fileno]['addr'][0], "port": self._sockets[fileno]['addr'][1], "fileno": fileno, "payload": data, "nodes": self._nodes
+ }
+ },
+ level=logging.INFO
+ )
```

With the following Yapf configuration:
```toml
[tool.yapf]
BASED_ON_STYLE = "pep8"
COLUMN_LIMIT = 236
USE_TABS = true
CONTINUATION_ALIGN_STYLE = "VALIGN-RIGHT"
SPACES_BEFORE_COMMENT = 1
SPLIT_BEFORE_FIRST_ARGUMENT = true
SPLIT_BEFORE_CLOSING_BRACKET = true
SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES = true
INDENT_DICTIONARY_VALUE = true
SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED = false
DEDENT_CLOSING_BRACKETS = true
SPACE_BETWEEN_ENDING_COMMA_AND_CLOSING_BRACKET = true
SPLIT_BEFORE_DICT_SET_GENERATOR = true
EACH_DICT_ENTRY_ON_SEPARATE_LINE = true
```

I would have assumed (new to Yapf) that setting `EACH_DICT_ENTRY_ON_SEPARATE_LINE` would affect all entries of a dictionary, not just the top level. It can probably be achieved by lowering the column limit (or some other way?) but I'd prefer to be able to tweak the outcome independently of each other.

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.