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

Continuation of #2094: unstable formatting #2137

Closed
felixhekhorn opened this issue Apr 26, 2021 · 2 comments
Closed

Continuation of #2094: unstable formatting #2137

felixhekhorn opened this issue Apr 26, 2021 · 2 comments
Labels
C: unstable formatting Formatting changed on the second pass T: bug Something isn't working

Comments

@felixhekhorn
Copy link

Hey @ichard26 !
Thanks a lot for your work! If I understood you correctly it is correct to open a new issue, right? (instead of commenting on the old?)

are you sure, this is fixed? because it still occurs on master which includes PR #2126 by now

I'm not sure it is related to magic commata but instead I believe it is related to the comments: look at the diff:

assert sorted(
-        [*triv_ops, "T15.c+", "V15.c-"] #, "c+.c+"", "c-.c-"]
+        [*triv_ops, "T15.c+", "V15.c-"]  # , "c+.c+"", "c-.c-"]
     ) == get_ad_to_evol_map(3, [4])

and using this snippet (with one comment removed) does indeed work as expected:

def test_ad_to_evol_map():
    triv_ops = ("S.S", "S.g", "g.S", "g.g", "V.V", "V3.V3", "T3.T3", "V8.V8", "T8.T8")
    # nf=3
    assert sorted(triv_ops) == get_ad_to_evol_map(3)
    # nf=3 + IC
    assert sorted(
        [*triv_ops, "T15.c+", "V15.c-"] #, "c+.c+"", "c-.c-"]
    ) == get_ad_to_evol_map(3, [4])
    # nf=3 + IC + IB
    assert sorted(
        [*triv_ops,"T15.c+", "V15.c-","b+.b+", "b-.b-"]
    ) == get_ad_to_evol_map(3, [4, 5])
    # nf=4 + IC + IB
    ks = sorted(
        [*triv_ops, "V15.V15", "T15.T15","T24.b+", "V24.b-"] # , "b+.b+", "b-.b-"]
    )
    assert ks == get_ad_to_evol_map(4, [4, 5])
    # nf=4 + IB
    assert ks == get_ad_to_evol_map(4, [5])
    # nf=6
    assert sorted(
        [*triv_ops, "T15.T15", "V15.V15", "T24.T24", "V24.V24", "T35.T35", "V35.V35"]
    ) == get_ad_to_evol_map(6)

also note that the diff snippet is not related to the comment, that I removed

@felixhekhorn felixhekhorn added the T: bug Something isn't working label Apr 26, 2021
@ichard26
Copy link
Collaborator

ichard26 commented Apr 26, 2021

it is correct to open a new issue, right? (instead of commenting

In hindsight it probably would've been better to explicitly allow follow up comments if the formatting was still unstable, but yes it's usually better still. I can't rename the issues, so I didn't want people to follow up with comments of how the output needs tweaking or there's now an invalid code produced bug, I can't edit the issue enough to turn into those other types.

By the way, are you sure this fails on master, black.now.sh's master version seems to be getting stuck on commit cac1829 which doesn't have the instability fix. Here's what's happening locally:

~/programming/oss/black on main [$?⇡] via Python v3.8.5 (black) 
❯ black --version
black, version 21.4b0

~/programming/oss/black on main [$?⇡] via Python v3.8.5 (black) took 336ms 
❯ git log -n5 --oneline
67d5532 (HEAD -> main, tag: 21.4b0, upstream/master) Update CHANGES.md for release (#2129)
de7187a Issue 1629 has been closed, let's celebrate! (#2127)
eee949e Docker CI: Add missed Checkout step (#2128)
e5490e9 (master) Add Docker Github Action (#2086)
8672af3 Work around stability errors due to optional trailing commas (#2126)

~/programming/oss/black on main [$?⇡] via Python v3.8.5 (black) 
❯ vim test.py

~/programming/oss/black on  main [$?⇡] via  v3.8.5 (black) took 4s954ms 
❯ cat test.py
def test_ad_to_evol_map():
    triv_ops = ("S.S", "S.g", "g.S", "g.g", "V.V", "V3.V3", "T3.T3", "V8.V8", "T8.T8")
    # nf=3
    assert sorted(triv_ops) == get_ad_to_evol_map(3)
    # nf=3 + IC
    assert sorted(
        [*triv_ops, "T15.c+", "V15.c-"] #, "c+.c+"", "c-.c-"]
    ) == get_ad_to_evol_map(3, [4])
    # nf=3 + IC + IB
    assert sorted(
        [*triv_ops,"T15.c+", "V15.c-","b+.b+", "b-.b-"]#, "c+.c+"", "c-.c-", "b+.b+", "b-.b-"]
    ) == get_ad_to_evol_map(3, [4, 5])
    # nf=4 + IC + IB
    ks = sorted(
        [*triv_ops, "V15.V15", "T15.T15","T24.b+", "V24.b-"] # , "b+.b+", "b-.b-"]
    )
    assert ks == get_ad_to_evol_map(4, [4, 5])
    # nf=4 + IB
    assert ks == get_ad_to_evol_map(4, [5])
    # nf=6
    assert sorted(
        [*triv_ops, "T15.T15", "V15.V15", "T24.T24", "V24.V24", "T35.T35", "V35.V35"]
    ) == get_ad_to_evol_map(6)

~/programming/oss/black on main [$?⇡] via Python v3.8.5 (black) 
❯ black test.py --config=tests/empty.toml --check --safe 
would reformat test.py
Oh no! 💥 💔 💥
1 file would be reformatted.

~/programming/oss/black on main [$?⇡] via Python v3.8.5 (black) took 432ms 
1❯ black test.py --config=tests/empty.toml --check --safe --diff
--- test.py	2021-04-26 11:36:38.934699 +0000
+++ test.py	2021-04-26 11:37:31.408594 +0000
@@ -2,19 +2,28 @@
     triv_ops = ("S.S", "S.g", "g.S", "g.g", "V.V", "V3.V3", "T3.T3", "V8.V8", "T8.T8")
     # nf=3
     assert sorted(triv_ops) == get_ad_to_evol_map(3)
     # nf=3 + IC
     assert sorted(
-        [*triv_ops, "T15.c+", "V15.c-"] #, "c+.c+"", "c-.c-"]
+        [*triv_ops, "T15.c+", "V15.c-"]  # , "c+.c+"", "c-.c-"]
     ) == get_ad_to_evol_map(3, [4])
     # nf=3 + IC + IB
-    assert sorted(
-        [*triv_ops,"T15.c+", "V15.c-","b+.b+", "b-.b-"]#, "c+.c+"", "c-.c-", "b+.b+", "b-.b-"]
-    ) == get_ad_to_evol_map(3, [4, 5])
+    assert (
+        sorted(
+            [
+                *triv_ops,
+                "T15.c+",
+                "V15.c-",
+                "b+.b+",
+                "b-.b-",
+            ]  # , "c+.c+"", "c-.c-", "b+.b+", "b-.b-"]
+        )
+        == get_ad_to_evol_map(3, [4, 5])
+    )
     # nf=4 + IC + IB
     ks = sorted(
-        [*triv_ops, "V15.V15", "T15.T15","T24.b+", "V24.b-"] # , "b+.b+", "b-.b-"]
+        [*triv_ops, "V15.V15", "T15.T15", "T24.b+", "V24.b-"]  # , "b+.b+", "b-.b-"]
     )
     assert ks == get_ad_to_evol_map(4, [4, 5])
     # nf=4 + IB
     assert ks == get_ad_to_evol_map(4, [5])
     # nf=6
would reformat test.py
Oh no! 💥 💔 💥
1 file would be reformatted.

@ichard26 ichard26 added the C: unstable formatting Formatting changed on the second pass label Apr 26, 2021
@felixhekhorn
Copy link
Author

Yes, you're right - the snippet does work locally with 21.4b0 correctly

Just for my future education:

  1. check the version in the playground explicitly (which is already printed, I realized now) and compare to git
  2. continue on the issue if it is still not working

do you agree? Maybe concerning 1. you may want to adjust your bug template? Or adjust the playground to display a warning, if not even with master?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: unstable formatting Formatting changed on the second pass T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants