]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Ensure match/case are recognized as statements (#2665)
authorBatuhan Taskaya <isidentical@gmail.com>
Thu, 2 Dec 2021 17:58:22 +0000 (20:58 +0300)
committerGitHub <noreply@github.com>
Thu, 2 Dec 2021 17:58:22 +0000 (09:58 -0800)
CHANGES.md
src/black/nodes.py
tests/data/pattern_matching_style.py [new file with mode: 0644]
tests/test_format.py

index 590429141740e6d019da698bb2e6b4bba217a338..c9a4f09a72a8b88b1439223ca9e085d81dc50315 100644 (file)
@@ -13,6 +13,7 @@
   `match a, *b:` (#2639) (#2659)
 - Fix `match`/`case` statements that contain `match`/`case` soft keywords multiple
   times, like `match re.match()` (#2661)
+- Fix `case` statements with an inline body (#2665)
 - Fix assignment to environment variables in Jupyter Notebooks (#2642)
 - Add `flake8-simplify` and `flake8-comprehensions` plugins (#2653)
 - Fix determination of f-string expression spans (#2654)
index 36dd18905114506ec0cac5c920dea482b02899b0..437051d3f6d5634910af587d2d4eec3cce574f8e 100644 (file)
@@ -52,6 +52,8 @@ STATEMENT: Final = {
     syms.with_stmt,
     syms.funcdef,
     syms.classdef,
+    syms.match_stmt,
+    syms.case_block,
 }
 STANDALONE_COMMENT: Final = 153
 token.tok_name[STANDALONE_COMMENT] = "STANDALONE_COMMENT"
diff --git a/tests/data/pattern_matching_style.py b/tests/data/pattern_matching_style.py
new file mode 100644 (file)
index 0000000..c1c0aee
--- /dev/null
@@ -0,0 +1,27 @@
+match something:
+    case b(): print(1+1)
+    case c(
+        very_complex=True,
+        perhaps_even_loooooooooooooooooooooooooooooooooooooong=-   1
+    ): print(1)
+    case c(
+        very_complex=True,
+        perhaps_even_loooooooooooooooooooooooooooooooooooooong=-1
+    ): print(2)
+    case a: pass
+
+# output
+
+match something:
+    case b():
+        print(1 + 1)
+    case c(
+        very_complex=True, perhaps_even_loooooooooooooooooooooooooooooooooooooong=-1
+    ):
+        print(1)
+    case c(
+        very_complex=True, perhaps_even_loooooooooooooooooooooooooooooooooooooong=-1
+    ):
+        print(2)
+    case a:
+        pass
index f97d7165b1af353278200aa6610e4782a5df35be..d44be1e8712ba6fa6a116f9c066f0493779cbffa 100644 (file)
@@ -74,6 +74,7 @@ PY310_CASES = [
     "pattern_matching_simple",
     "pattern_matching_complex",
     "pattern_matching_extras",
+    "pattern_matching_style",
     "parenthesized_context_managers",
 ]