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

Disabling black on a long condition of if statement #2864

Closed
Akuli opened this issue Feb 3, 2022 · 1 comment
Closed

Disabling black on a long condition of if statement #2864

Akuli opened this issue Feb 3, 2022 · 1 comment
Labels
F: fmtoff fmt: off implementation R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@Akuli
Copy link

Akuli commented Feb 3, 2022

Describe the bug

internal error

To Reproduce

class GameOverView:
    def handle_key_press(self, received: bytes) -> bool:
        # fmt: off
        if received in (DOWN_ARROW_KEY, b"S", b"s") and i+1 < len(self._all_menu_items):
        # fmt: on
            self._selected_item = self._all_menu_items[i + 1]


class Client:
    pass

Run black file.py with no arguments. The resulting error is:

error: cannot format blackbug.py: INTERNAL ERROR: Black produced code that is not equivalent to the source on pass 1. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /tmp/blk_0gcejoy4.log

here have diff
--- src
+++ dst
@@ -218,22 +218,22 @@
                 'bool',  # str
             )  # /Name
           type_comment=
             None,  # NoneType
         )  # /FunctionDef
+        ClassDef(
+          bases=
+          body=
+            Pass(
+            )  # /Pass
+          decorator_list=
+          keywords=
+          name=
+            'Client',  # str
+        )  # /ClassDef
       decorator_list=
       keywords=
       name=
         'GameOverView',  # str
     )  # /ClassDef
-    ClassDef(
-      bases=
-      body=
-        Pass(
-        )  # /Pass
-      decorator_list=
-      keywords=
-      name=
-        'Client',  # str
-    )  # /ClassDef
   type_ignores=
 )  # /Module
\ No newline at end of file

Expected behavior

No error. Leave formatting unchanged.

Environment

  • Black's version: main
  • OS and Python version: black.vercel.app
@Akuli Akuli added the T: bug Something isn't working label Feb 3, 2022
@felix-hilden felix-hilden added the F: fmtoff fmt: off implementation label Feb 3, 2022
@JelleZijlstra
Copy link
Collaborator

This is basically the same as #2567

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: fmtoff fmt: off implementation R: duplicate This issue or pull request already exists T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants