prettyprinter icon indicating copy to clipboard operation
prettyprinter copied to clipboard

trailing commas

Open anntzer opened this issue 6 years ago • 1 comments

  • PrettyPrinter version: 0.16.0
  • Python version: 3.7
  • Operating System: linux

Description

Currently, prettyprinter formats collections without a comma after the last element. Adding a comma there is optional, but suggested in some style guides, including PEP8 (https://www.python.org/dev/peps/pep-0008/#when-to-use-trailing-commas). It would be nice if prettyprinter also added the comma (or provided a configurable option to do so).

What I Did

In [1]: sys.version_info                                                                                                                                                                            
Out[1]: 
sys.version_info((
    3,  # major
    7,  # minor
    2,  # micro
    'final',  # releaselevel
    0  # serial
))

expected a comma in 0, # serial.

anntzer avatar Mar 11 '19 23:03 anntzer

I agree, I think we can add this as a configurable option. I'll see if I can make this change sometime this week to ship in a new release with the PRs I merged in today.

tommikaikkonen avatar Mar 12 '19 05:03 tommikaikkonen