File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -930,7 +930,7 @@ def visit_ClassDef(self, node):
930930 self .fill ("@" )
931931 self .traverse (deco )
932932 self .fill ("class " + node .name )
933- with self .delimit ("(" , ")" ):
933+ with self .delimit_if ("(" , ")" , condition = node . bases or node . keywords ):
934934 comma = False
935935 for e in node .bases :
936936 if comma :
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ class Foo: pass
110110
111111docstring_prefixes = [
112112 "" ,
113- "class foo() :\n " ,
113+ "class foo:\n " ,
114114 "def foo():\n " ,
115115 "async def foo():\n " ,
116116]
@@ -367,6 +367,19 @@ def test_simple_expressions_parens(self):
367367 self .check_src_roundtrip ("call((yield x))" )
368368 self .check_src_roundtrip ("return x + (yield x)" )
369369
370+
371+ def test_class_bases_and_keywords (self ):
372+ self .check_src_roundtrip ("class X:\n pass" )
373+ self .check_src_roundtrip ("class X(A):\n pass" )
374+ self .check_src_roundtrip ("class X(A, B, C, D):\n pass" )
375+ self .check_src_roundtrip ("class X(x=y):\n pass" )
376+ self .check_src_roundtrip ("class X(metaclass=z):\n pass" )
377+ self .check_src_roundtrip ("class X(x=y, z=d):\n pass" )
378+ self .check_src_roundtrip ("class X(A, x=y):\n pass" )
379+ self .check_src_roundtrip ("class X(A, **kw):\n pass" )
380+ self .check_src_roundtrip ("class X(*args):\n pass" )
381+ self .check_src_roundtrip ("class X(*args, **kwargs):\n pass" )
382+
370383 def test_docstrings (self ):
371384 docstrings = (
372385 '"""simple doc string"""' ,
You can’t perform that action at this time.
0 commit comments