Possible to wrap code, including string literals?

Thanks to PEP8 and Guido, some members of the Python community get very excitable about code that is wider than 79 characters.

I notice that there is limited support for smart code wrapping, but it would be "pleasurable" if this support were extended.

How nice would it be to be able to automatically reformat this:

    file_name = models.CharField(max_length=256,

                                 help_text='The original filename from the source lab, as uploaded to the FTP site, '

                                           'including any subdirectories if those exist (Note: All files will be renamed using '

                                           'a standard format along with a unique id before being made public) String composed '

                                           'of standard allowed filename characters (e.g. "s_1_1_sequence.txt")')

to this:
    file_name = models.CharField(max_length=256,
                                 help_text='The original filename from the'
                                 ' source lab, as uploaded to the FTP site,'
                                 ' including any subdirectories if those exist'
                                 '. (Note: All files will be renamed using'
                                 ' a standard format along with a unique id'
                                 ' before being made public) String composed'
                                 ' of standard allowed filename characters'
                                 ' (e.g. "s_1_1_sequence.txt").')
based on the user-specified right margin.
It's even imaginable to have an option to dynamically wrap string literals as you type according to a specified style (implicit concatenation, explicit concatenation, no concatenation).
2 comments
Comment actions Permalink

Hello Kevin,

There are in fact options for that: Settings | Code Style | Wrapping and

Braces | Ensure right margin is not exceeded, Settings | Code Style | General

| Wrap when typing reaches right margin.

The formatter engine is currently not smart enough to perform word-by-word

reflow of multiline string literals, and I don't expect this to become supported

in the near future, but for simpler cases these should do what you need.

Thanks to PEP8 and Guido, some members of the Python community get

very excitable about code that is wider than 79 characters.

I notice that there is limited support for smart code wrapping, but it

would be "pleasurable" if this support were extended.

How nice would it be to be able to automatically reformat this:

file_name = models.CharField(max_length=256,

help_text='The original filename from

the source lab, as uploaded to the FTP site, '

'including any

subdirectories if those exist (Note: All files will be renamed using '

'a standard format along

with a unique id before being made public) String composed '

'of standard allowed

filename characters (e.g. "s_1_1_sequence.txt")')

to this:

file_name = models.CharField(max_length=256,

help_text='The original filename from

the'

' source lab, as uploaded to the FTP

site,'

' including any subdirectories if

those exist'

'. (Note: All files will be renamed

using'

' a standard format along with a

unique id'

' before being made public) String

composed'

' of standard allowed filename

characters'

' (e.g. "s_1_1_sequence.txt").')

based on the user-specified right margin.

It's even imaginable to have an option to dynamically wrap string

literals as you type according to a specified style (implicit

concatenation, explicit concatenation, no concatenation).

---

Original message URL:

http://devnet.jetbrains.net/message/5317529#5317529

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0
Comment actions Permalink

Summary: the formatter is not sophisticated enough yet.  I'll just have to fantasize in the meantime.  The option to wrap when typing reaches the right margin is slightly annoying when dealing with string literals.

0

Please sign in to leave a comment.