Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black is not respecting max line length with string that use format function #3622

Closed
matejsp opened this issue Mar 24, 2023 · 2 comments
Closed
Labels
T: bug Something isn't working

Comments

@matejsp
Copy link

matejsp commented Mar 24, 2023

Describe the bug

We are using latest black 23.1.0 and it is putting .format after string making line longer than required.

Solution is to use experimental-string-processing however it will probably be removed due to its functionality moved to future.
However the problem is that future contains also other improvements and we don't want the style to change with each black upgrade.

To Reproduce

Black configuration:

[tool.black]
line-length = 120
target-version = ['py38']

Code runned with black (note line is 125 lines long and too long and flake8 checking breaks):

import datetime
import logging

logger = logging.getLogger(__name__)

if __name__ == "__main__":
    delay_until_gt = datetime.datetime.now()
    logger.info(
        "Resetting delay_until for all tasks virtual command queue objects that have delay greater or equal than {0}".format(
            delay_until_gt
        )
    )

Code runned with black (experimental-string-processing = true):

import datetime
import logging

logger = logging.getLogger(__name__)

if __name__ == "__main__":
    delay_until_gt = datetime.datetime.now()
    logger.info(
        "Resetting delay_until for all tasks virtual command queue objects that have delay greater or equal than {0}"
        .format(delay_until_gt)
    )

And run it with these arguments:

$ black --target-version py38 file.py
$ black --target-version py38 --experimental-string-processing file.py

Expected behavior
I should get line no longer than 120 chars

Environment

  • Black's version: 23.1.0
  • OS and Python version: MacOSX Ventura 13.2 python 3.8, Amazon Linux 2023 -> python 3.11
@matejsp matejsp added the T: bug Something isn't working label Mar 24, 2023
@JelleZijlstra
Copy link
Collaborator

As you say, this is fixed in the preview style, and therefore likely to be in the stable style for next year. Our policy is not to change the style during the year, so there's nothing else to do here.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2023
@matejsp
Copy link
Author

matejsp commented Mar 24, 2023

Except it was already in preview last year :D Just hope you don't remove --experimental-string-processing this year and we are ok with it.

But it is still a bug in 2023 style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants