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.

Update the `black` version and format the strings

See original GitHub issue

🚀 Feature

We currently use black version 19.10b0. The idea is to upgrade to the version 21.9b0 and use the following option

black . --experimental-string-processing

to format strings.

This should be included in the script run_code_style.sh

bash ./tests/run_code_style.sh fmt

A point is to check and report the impact of the upgrade.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vfdev-5commented, Oct 6, 2021

in case of

# original
train_loader = idist.auto_dataloader(
    train_dataset, batch_size=config["batch_size"], num_workers=config["num_workers"], shuffle=True, drop_last=True,
)

# black
train_loader = idist.auto_dataloader(
    train_dataset,
    batch_size=config["batch_size"],
    num_workers=config["num_workers"],
    shuffle=True,
    drop_last=True,
)

the last comma after drop_last=True, makes it line by line. If you remove it, it should be unexpanded.

1reaction
vfdev-5commented, Oct 6, 2021

@sdesrozis can you try locally that ? The last time I tried that and black reformatted a lot of code into ugly things like:

a = [
    func(
       a,
       b,
       12,
    ),
    124
]

That was principal blocker to update. If the newest version does not produce weird result and our codebase remains practially the same I’d agree to update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Black code style - Black 22.12.0 documentation
Black ignores previous formatting and applies uniform horizontal and vertical ... It will also enable a future version of Black to merge consecutive...
Read more >
Black Fails to Format Single String Longer Than Line Length ...
Describe the bug A Python file containing a single string assignment longer than the line length limit is not reformatted.
Read more >
How to automatically break long string constants in Python ...
First make sure that you have a very recent Black formatter installed. Now just run black with the option --experimental-string-processing . In ...
Read more >
Python 3's f-Strings: An Improved String Formatting Syntax ...
As of Python 3.6, f-strings are a great new way to format strings. Not only are they more readable, more concise, and less...
Read more >
Plain Text Formatting - F# | Microsoft Learn
Learn how to use printf and other plain text formatting in F# applications and scripts.
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