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

Strings not being formatted by Black #4356

Closed
krusion opened this issue May 9, 2024 · 3 comments
Closed

Strings not being formatted by Black #4356

krusion opened this issue May 9, 2024 · 3 comments
Labels
T: bug Something isn't working

Comments

@krusion
Copy link

krusion commented May 9, 2024

Describe the bug

Strings longer than my set character limit (79) don't get formatted like the rest of the code.

To Reproduce

For example, take this code:

string = "test test test test test test test test test test test test test test test test test test test test test test test test test test test test test"

Expected behavior

A string split over 2 lines.

Environment

  • Black's version: v2024.2.0
  • OS and Python version: Windows 10, Python 3.12.2. Running in VS code

Additional context

I saw posts about this being fixed by adding "--preview" Argument. That didn't help. However, read on multiple issues that it will be the default setting starting in 2024.

These are my settings:

"editor.defaultFormatter": "ms-python.black-formatter",
    "editor.formatOnSave": true,
    "black-formatter.args": [
        "--line-length",
        "79",
        "--preview",
    ],

    "editor.codeActionsOnSave": {
        "source.organizeImports": "explicit"
    },

Should this also work with comments or just strings?

@krusion krusion added the T: bug Something isn't working label May 9, 2024
@cobaltt7
Copy link
Contributor

cobaltt7 commented May 9, 2024

I saw posts about this being fixed by adding "--preview" Argument. That didn't help. However, read on multiple issues that it will be the default setting starting in 2024.

That was the case for many preview formats, however this specific one was moved under the new --unstable flag instead. See also #4208

@krusion
Copy link
Author

krusion commented May 9, 2024

I see! I'm a little bit confused, so what's the argument now if I want to test if it'll help me or not? Like what should I add in my settings file?

@JelleZijlstra
Copy link
Collaborator

You can add unstable = true. However, at this point we're likely to drop this feature (see the issue @RedGuy12 linked).

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2024
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

3 participants