google / google/yapf

"visually indented line with same indent as next logical line" on function def

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

Description

With 0.29, there is a regression on the way function definition is defined.

For example, Before this was formatted correctly by yapf:
```python
# when using click, long function def can happen

def entrypoint(
ctx,
mode,
config,
# only,
myserver,
projects,
verbose,
validate,
myserver_url,
myserver_token,
report_file,
report_html,
color,
diff,
debug,
config_project_url,
configured_by_mytool_badge_url,
accepted_external_badge_image_urls,
smtp_server,
smtp_port,
watchers,
sentry_dsn,
gelf_host,
gelf_level,
old_configured_by_mytool_badge_urls):
if color == "force":
if color == "force":
ctx.color = True
```

After 0.27:
```python

def entrypoint(
ctx,
mode,
config,
# only,
myserver,
projects,
verbose,
validate,
myserver_url,
myserver_token,
report_file,
report_html,
color,
diff,
debug,
config_project_url,
configured_by_mytool_badge_url,
accepted_external_badge_image_urls,
smtp_server,
smtp_port,
watchers,
sentry_dsn,
gelf_host,
gelf_level,
old_configured_by_mytool_badge_urls):
if color == "force":
...
```

I would like to keep the old behavior, because I find much more maintainable, to be able to distinguish between list of parameter and the indentation of the block.

At least please provide an option/knob, such as "overindent_def", so that user can opt-in if they want.

Today, I have to yapf:disable these block

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.