[Python-ideas] PEP 8 update on line length

Jonathan Fine jfine2358 at gmail.com
Wed Feb 20 14:45:10 EST 2019


I wrote:
<quote>
<https://github.com/samuelcolvin/pydantic/blob/master/pydantic/utils.py#L246>

def resolve_annotations(raw_annotations: Dict[str, AnyType],
module_name: Optional[str]) -> Dict[str, AnyType]:
        pass

After using https://black.now.sh/

def resolve_annotations(
    raw_annotations: Dict[str, AnyType],
    module_name: Optional[str],
) -> Dict[str, AnyType]:
    pass
</endquote>

Samuel Colvin then told us that his example was already formatted with
black.py, using a long line length.

Here's a suggestion, at least for people projects that use black.py
(such as Samuel's). It is to use black.py with a line-length of say 80
characters for code that is saved in version control. And when editing
code, use whatever line-length that happens to suit the tools you are
using.

Indeed, like a word-processor, one could use black.py to 'line-wrap'
the Python code to what is the current width of the editor window.

Indeed, this might be a useful feature in Jupyter - see
https://github.com/drillan/jupyter-black.  And I've created
https://github.com/drillan/jupyter-black/issues/3
Perhaps set the black line length to the width of the text box

-- 
Jonathan


More information about the Python-ideas mailing list