Skip to content

Unstable formatting on subscripted assignment + string + comment #1598

@JelleZijlstra

Description

@JelleZijlstra
$ cat test_ranking_store.py 
value.__dict__[
    key
] = "test"  # set some Thrift field to non-None in the struct aa bb cc dd ee
$ black -v test_ranking_store.py 
Using configuration from /Users/jelle/py/black/pyproject.toml.
error: cannot format test_ranking_store.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/wx/zkst6jdx1zg_s32d23gz4_0r0000gn/T/blk_mf5ru27i.log
Oh no! 💥 💔 💥
1 file failed to reformat.
$ cat  /var/folders/wx/zkst6jdx1zg_s32d23gz4_0r0000gn/T/blk_mf5ru27i.log
--- source
+++ first pass
@@ -1,3 +1,5 @@
 value.__dict__[
     key
-] = "test"  # set some Thrift field to non-None in the struct aa bb cc dd ee
+] = (  # set some Thrift field to non-None in the struct aa bb cc dd ee
+    "test"
+)
--- first pass
+++ second pass
@@ -1,5 +1,3 @@
 value.__dict__[
     key
-] = (  # set some Thrift field to non-None in the struct aa bb cc dd ee
-    "test"
-)
+] = "test"  # set some Thrift field to non-None in the struct aa bb cc dd ee

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: unstable formattingFormatting changed on the second passT: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions