question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to prevent YAPF from joining lines in dictionaries and lists?

See original GitHub issue

YAPF converts

DJANGO_TEMPLATES_OPTIONS = {
  "context_processors": []
}

to

DJANGO_TEMPLATES_OPTIONS = {"context_processors": []}

and I cannot find the option to disable such behavior.

Is it possible?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
audiolioncommented, Feb 8, 2017

I would love to see this as well. A case I keep coming across:


class Status(models.Model):
    
    STATUS_CHOICES = (
        ('g', 'Green'),
        ('y', 'Yellow'),
        ('r', 'Red'),
    )
    ..

Becomes


class Status(models.Model):
     
     STATUS_CHOICES = (('g', 'Green'), ('y', 'Yellow'), ('r', 'Red'),)
     ..

Which is less readable in my opinion.

4reactions
aaducommented, May 19, 2017

Any update on ensuring tuple elements are each on their own line?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to configure YAPF to use hanging indentation for long ...
Check this: SPLIT_BEFORE_FIRST_ARGUMENT If an argument / parameter list is going to be split, then split before the first argument. yapf ...
Read more >
yapf/yapflib/style.py - platform/external/yapf - Git at Google
Allow dictionary keys to exist on multiple lines. For example: ... Disable the heuristic which places each list element on a separate line....
Read more >
yapf · PyPI
Disable the heuristic which places each list element on a separate line if the list is comma-terminated. EACH_DICT_ENTRY_ON_SEPARATE_LINE. Place each dictionary ...
Read more >
How to automate Python code formatting | by AlexV - Medium
Dictionaries should have a key and value on each line with a comma at the end. ... Then to combine this with YAPF...
Read more >
Code Style. Python | PyCharm Documentation - JetBrains
The left-hand pane contains the list of exceptions (Keep when reformatting), ... If your code contains lines that are shorter than a standard...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found