google / google/styleguide

Should python function argument definitions be indented 4 or 8 spaces?

Open
#545 3 comments 1 reaction 1 assignee Claimed by @gpshead View on GitHub
lang:python
Dominant language
HTML
Stars
39.6k
Forks
12.9k
Avg merge
42m
Merged PRs (30d)
15

Description

YAPF recently [changed](https://github.com/google/yapf/issues/793) from indenting like

```python
def f(
a: str,
b: str,
) -> None:
pass
```

to:

```python
def f(
a: str,
b: str,
) -> None:
pass
```

I thought the first way was correct, but looking at the style guide more, I'm not actually sure what the correct behavior is. The [indentation section](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#s3.4-indentation) doesn't say anything about function arguments in a def statement. The [type annotation line breaking section](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#3192-line-breaking) does have examples, but those follow Google's internal 2-space indentation style instead of the external 4-space style.

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.