psf / psf/black

no opinion on tuple assignment parentheses?

Open
#445 7 comments 18 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

F: parentheses T: enhancement
Dominant language
Python
Stars
41.8k
Forks
2.9k
Avg merge
5d 6h
Merged PRs (30d)
9

Description

This might be intentional but it feels like an omission, so I'm reporting it.

Does Black not have an opinion on parentheses around tuples, when assigning or returning? The following file remains untouched:

(a, b, c) = 1, 2, 3
a, b, c = (1, 2, 3)
return (d, e, f)
return 1, 2, 3

I would expect the optional parentheses would be removed in all above cases, per this: "In those cases, parentheses are removed when the entire statement fits in one line, or if the inner expression doesn't have any delimiters to further split on."

Operating system: Linux Mint
Python version: 3.6
Black version: 18.6b4
Does also happen on master: yes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Reproduce the four Python examples with Black 18.6b4 or current master, compare the output with the quoted parenthesis rule, and trace the formatter behavior for tuple assignment and return statements. Done means the chosen behavior is covered by regression tests and is consistent with Black's documented formatting rules.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.