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.

Black fails to format over-length line containing walrus operator (works on master)

See original GitHub issue

Describe the bug As per title - lines longer than 88 containing a walrus operator fail to be formatted.

It works on master though (tested in the online version)

To Reproduce Steps to reproduce the behavior:

  1. Take this code
longnamelongnamelongnamelongnamelongnamelongnamelongnamelongname = 5
if x := longnamelongnamelongnamelongnamelongnamelongnamelongnamelongname + longnamelongnamelongnamelongnamelongnamelongnamelongnamelongname:
    print(x)
  1. Run Black on it
  2. See error

Expected behavior A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • Version: 19.10b0
  • OS and Python version: windows 10, python 3.8.0

Does this bug also happen on master? It does work on master - tested on online version. Looks like we just need a new release.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
aberriercommented, Mar 27, 2020

Do we have an approximate time of when the release will come up? 😃

5reactions
jcusick13commented, Dec 8, 2019

I’m also running into an issue with the walrus operator, though it seems to be independent of line length. When running black on a file, it fails on this line

while (foo := my_func(bar)) >= 0:

providing

cannot use --safe with this file; failed to parse source file. AST error message: invalid syntax (<unknown>, line 12)

By removing the walrus operator from that line, black is successfully able to format the file.

Environment

  • black version 19.10b
  • Python 3.8.0
  • Ubuntu 18.04.3

Does this bug happen on master? No, this bug does not occur on the master branch. I agree with Martin about the new release.

Thanks for all of the work thus far! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Despite controversy, walrus operator is going to be like f ...
The long length of calls to "format" is what screws up your indentation, which then screws up the literals (or forces you to...
Read more >
In python, how to tweak Black formatter, if possible?
This is due to the default line length for black being longer than you'd like – 88 characters per line. To decrease the...
Read more >
Hyperion System 9 BI+ Production Reporting Developer's ...
first column. The characters "!=" denotes a relational operator, and Production. Reporting could confuse it with a comment where a relational argument could....
Read more >
if you liked this book, try… - SCASL
SUMMARY: When Naomi's absent mother resurfaces to claim her, Naomi runs away to Mexico with her great-grandmother and younger brother in search of...
Read more >
ALPS: A Bluetooth and Ultrasound Platform for Mapping and ...
classify if beacons are within Line-Of-Sight (LOS) to the mobile phone. ... tion with a Euclidean distance error of 16.1cm, and can gen-....
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