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

string_processing: Crash with comment inside implicitly concatenated string (and --line-length 4) #3428

Open
JelleZijlstra opened this issue Dec 10, 2022 · 0 comments
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. F: strings Related to our handling of strings T: bug Something isn't working

Comments

@JelleZijlstra
Copy link
Collaborator

inline_comments_func2(
    " this part does not fit into a single line? "
    # x
    "it into parts that fit in line length.",
)

On 22.12.0:

% black --diff tests/data/preview/long_strings.py -l 4 --preview
error: cannot format tests/data/preview/long_strings.py: INTERNAL ERROR: Black produced code that is not equivalent to the source.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/3b/k964cnv10097wzj3h7w07fww0000gp/T/blk_m7_0sao2.log

Oh no! 💥 💔 💥
1 file would fail to reformat.
% cat /var/folders/3b/k964cnv10097wzj3h7w07fww0000gp/T/blk_m7_0sao2.log
--- src
+++ dst
@@ -2,16 +2,27 @@
   body=
     Expr(
       value=
         Call(
           args=
-            Constant(
-              kind=
-                None,  # NoneType
-              value=
-                'this part does not fit into a single line? it into parts that fit in line length.',  # str
-            )  # /Constant
+            Call(
+              args=
+                Constant(
+                  kind=
+                    None,  # NoneType
+                  value=
+                    'it into parts that fit in line length.',  # str
+                )  # /Constant
+              func=
+                Constant(
+                  kind=
+                    None,  # NoneType
+                  value=
+                    'this part does not fit into a single line?',  # str
+                )  # /Constant
+              keywords=
+            )  # /Call
           func=
             Name(
               ctx=
                 Load(
                 )  # /Load

It appears to insert a function call.

@JelleZijlstra JelleZijlstra added the T: bug Something isn't working label Dec 10, 2022
@JelleZijlstra JelleZijlstra added the C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. label Dec 19, 2022
@hauntsaninja hauntsaninja added the F: strings Related to our handling of strings label Sep 3, 2023
@JelleZijlstra JelleZijlstra changed the title Crash with comment inside implicitly concatenated string (and --line-length 4) string_processing: Crash with comment inside implicitly concatenated string (and --line-length 4) Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. F: strings Related to our handling of strings T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants