Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing comma prevents multiline -> single line #1982

Closed
jbnjohnathan opened this issue Feb 12, 2021 · 2 comments
Closed

Trailing comma prevents multiline -> single line #1982

jbnjohnathan opened this issue Feb 12, 2021 · 2 comments
Labels
R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@jbnjohnathan
Copy link

Describe the bug A clear and concise description of what the bug is.
When a python file contains a line split over several lines, which should be one line black does not compress it into one line if there is a trailing comma.

To Reproduce Steps to reproduce the behavior:

This code:

responseObject = jsonify(
    {
        "status": "success"
    }
)

Will be formatted to:

responseObject = jsonify({"status": "success"})

This is expected behaviour.

But if there is a trailing comma like this:

responseObject = jsonify(
    {
        "status": "success",
    }
)

The code will not be changed.

Expected behavior A clear and concise description of what you expected to happen.
I expect black to move the multiline statement to one line if the line will not be too long, regardless of the trailing comma.

Environment (please complete the following information):

  • Version: 20.8b1
  • OS and Python version: [e.g. Ubuntu/Python 3.6.9]

Does this bug also happen on master? To answer this, you have two options:
Yes it happens on master, tested with https://black.now.sh/?version=master

Additional context Add any other context about the problem here.

@jbnjohnathan jbnjohnathan added the T: bug Something isn't working label Feb 12, 2021
@MarcoGorelli
Copy link
Contributor

Is this the same as #1742 ?

@jbnjohnathan
Copy link
Author

Is this the same as #1742 ?

Ah yes indeed! Then this one can be closed as a duplicate

@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R: duplicate This issue or pull request already exists T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants