Repository: asottile/add-trailing-comma (python)

Issue:
`AssertionError: Past end?` on match statement class with no args
Interpreter: Python 3.10

Minimum breaking example:

```python
match 1:
    case str():  # `str()` seems to be important here!
        pass
    case _:
        pass
```

Probably related to #177 .

Pull request description:
skip fixing MatchClass with no args
resolves #181 

Patch:
diff --git a/add_trailing_comma/_plugins/match.py b/add_trailing_comma/_plugins/match.py
index 5ae804c..e0a30a9 100644
--- a/add_trailing_comma/_plugins/match.py
+++ b/add_trailing_comma/_plugins/match.py
@@ -38,8 +38,9 @@ if sys.version_info >= (3, 10):  # pragma: >=3.10 cover
     ) -> Iterable[tuple[Offset, TokenFunc]]:
         arg_offsets = {ast_to_offset(pat) for pat in node.patterns}
         arg_offsets |= {ast_to_offset(pat) for pat in node.kwd_patterns}
-        func = functools.partial(_fix_match_class, arg_offsets=arg_offsets)
-        yield ast_to_offset(node), func
+        if arg_offsets:  # can't add commas without args!
+            func = functools.partial(_fix_match_class, arg_offsets=arg_offsets)
+            yield ast_to_offset(node), func
 
     def _fix_mapping(i: int, tokens: list[Token]) -> None:
         fix_brace(


Test patch:
diff --git a/tests/features/match_test.py b/tests/features/match_test.py
index ed9b691..30b13d9 100644
--- a/tests/features/match_test.py
+++ b/tests/features/match_test.py
@@ -16,6 +16,12 @@ from add_trailing_comma._main import _fix_src
             '        pass\n',
             id='sequence without braces',
         ),
+        pytest.param(
+            'match x:\n'
+            '    case a():\n'
+            '        pass\n',
+            id='class without args',
+        ),
     ),
 )
 def test_noop(s):