@@ -725,6 +725,71 @@ def __init__(self, *args, **kwargs) -> None: ...
725
725
class X(`namedtuple-X-0`): ...
726
726
""" )
727
727
728
+ def test_trailing_comma (self ):
729
+ self .check ("""\
730
+ from typing import NamedTuple
731
+ Foo = NamedTuple(
732
+ "Foo",
733
+ [
734
+ ("a", int),
735
+ ("b", str),
736
+ ],
737
+ )
738
+ """ , """\
739
+ from typing import Any, Tuple, Type, TypeVar
740
+
741
+ Foo = `namedtuple-Foo-0`
742
+
743
+ _Tnamedtuple-Foo-0 = TypeVar('_Tnamedtuple-Foo-0', bound=`namedtuple-Foo-0`)
744
+
745
+ class `namedtuple-Foo-0`(Tuple[int, str]):
746
+ __slots__ = ["a", "b"]
747
+ a: int
748
+ b: str
749
+ _asdict: Any
750
+ __dict__: Any
751
+ _fields: Any
752
+ __getnewargs__: Any
753
+ __getstate__: Any
754
+ _make: Any
755
+ _replace: Any
756
+ def __new__(cls: Type[`_Tnamedtuple-Foo-0`], a: int, b: str) -> `_Tnamedtuple-Foo-0`: ...
757
+ def __init__(self, *args, **kwargs) -> None: ...
758
+ """ )
759
+
760
+ def test_collections_trailing_comma (self ):
761
+ self .check ("""\
762
+ from collections import namedtuple
763
+ Foo = namedtuple(
764
+ "Foo",
765
+ [
766
+ "a",
767
+ "b",
768
+ ],
769
+ )
770
+ """ , """\
771
+ from typing import Any, Tuple, Type, TypeVar
772
+
773
+ from collections import namedtuple
774
+ Foo = `namedtuple-Foo-0`
775
+
776
+ _Tnamedtuple-Foo-0 = TypeVar('_Tnamedtuple-Foo-0', bound=`namedtuple-Foo-0`)
777
+
778
+ class `namedtuple-Foo-0`(Tuple[Any, Any]):
779
+ __slots__ = ["a", "b"]
780
+ a: Any
781
+ b: Any
782
+ _asdict: Any
783
+ __dict__: Any
784
+ _fields: Any
785
+ __getnewargs__: Any
786
+ __getstate__: Any
787
+ _make: Any
788
+ _replace: Any
789
+ def __new__(cls: Type[`_Tnamedtuple-Foo-0`], a, b) -> `_Tnamedtuple-Foo-0`: ...
790
+ def __init__(self, *args, **kwargs) -> None: ...
791
+ """ )
792
+
728
793
def test_collections_namedtuple (self ):
729
794
expected = """\
730
795
from typing import Any, Tuple, Type, TypeVar
0 commit comments