Repository: asottile/pyupgrade

Issue:
metaclass extending object takes two passes to resolve
minor thing, would be a useful improvement:

```python
class C(six.with_metaclass(abc.ABCMeta, object)): pass
```



Discussion:

Patch:
diff --git a/pyupgrade.py b/pyupgrade.py
index 6f99694..1a80af6 100644
--- a/pyupgrade.py
+++ b/pyupgrade.py
@@ -2039,6 +2039,12 @@ def _fix_py3_plus(contents_text):  # type: (str) -> str
             func_args, end = _parse_call_args(tokens, j)
             if len(func_args) == 1:
                 tmpl = WITH_METACLASS_NO_BASES_TMPL
+            elif len(func_args) == 2:
+                base = tokens_to_src(tokens[slice(*func_args[1])]).strip()
+                if base == 'object':
+                    tmpl = WITH_METACLASS_NO_BASES_TMPL
+                else:
+                    tmpl = WITH_METACLASS_BASES_TMPL
             else:
                 tmpl = WITH_METACLASS_BASES_TMPL
             _replace_call(tokens, i, end, func_args, tmpl)


Test patch:
diff --git a/tests/six_test.py b/tests/six_test.py
index c58f5fc..18b35f4 100644
--- a/tests/six_test.py
+++ b/tests/six_test.py
@@ -260,6 +260,11 @@ def test_fix_six_noop(s):
 
             'class C(B, metaclass=M): pass',
         ),
+        (
+            'class C(six.with_metaclass(M, B1, B2)): pass',
+
+            'class C(B1, B2, metaclass=M): pass',
+        ),
         (
             'from six import with_metaclass\n'
             'class C(with_metaclass(M, B)): pass\n',
@@ -281,6 +286,15 @@ def test_fix_six_noop(s):
 
             id='weird spacing with_metaclass',
         ),
+        pytest.param(
+            'from six import with_metaclass\n'
+            'class C(with_metaclass(M, object)): pass',
+
+            'from six import with_metaclass\n'
+            'class C(metaclass=M): pass',
+
+            id='elide object base in with_metaclass',
+        ),
         pytest.param(
             '@six.add_metaclass(M)\n'
             'class C: pass\n',