@@ -427,17 +427,17 @@ def test_dump(self):
427
427
self .assertEqual (ast .dump (node ),
428
428
"Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), "
429
429
"args=[Name(id='eggs', ctx=Load()), Str(s='and cheese')], "
430
- "keywords=[], starargs=None, kwargs=None ))])"
430
+ "keywords=[]))])"
431
431
)
432
432
self .assertEqual (ast .dump (node , annotate_fields = False ),
433
433
"Module([Expr(Call(Name('spam', Load()), [Name('eggs', Load()), "
434
- "Str('and cheese')], [], None, None ))])"
434
+ "Str('and cheese')], []))])"
435
435
)
436
436
self .assertEqual (ast .dump (node , include_attributes = True ),
437
437
"Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load(), "
438
438
"lineno=1, col_offset=0), args=[Name(id='eggs', ctx=Load(), "
439
439
"lineno=1, col_offset=5), Str(s='and cheese', lineno=1, "
440
- "col_offset=11)], keywords=[], starargs=None, kwargs=None, "
440
+ "col_offset=11)], keywords=[], "
441
441
"lineno=1, col_offset=0), lineno=1, col_offset=0)])"
442
442
)
443
443
@@ -453,16 +453,16 @@ def test_copy_location(self):
453
453
def test_fix_missing_locations (self ):
454
454
src = ast .parse ('write("spam")' )
455
455
src .body .append (ast .Expr (ast .Call (ast .Name ('spam' , ast .Load ()),
456
- [ast .Str ('eggs' )], [], None , None )))
456
+ [ast .Str ('eggs' )], [])))
457
457
self .assertEqual (src , ast .fix_missing_locations (src ))
458
458
self .assertEqual (ast .dump (src , include_attributes = True ),
459
459
"Module(body=[Expr(value=Call(func=Name(id='write', ctx=Load(), "
460
460
"lineno=1, col_offset=0), args=[Str(s='spam', lineno=1, "
461
- "col_offset=6)], keywords=[], starargs=None, kwargs=None, "
461
+ "col_offset=6)], keywords=[], "
462
462
"lineno=1, col_offset=0), lineno=1, col_offset=0), "
463
463
"Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, "
464
464
"col_offset=0), args=[Str(s='eggs', lineno=1, col_offset=0)], "
465
- "keywords=[], starargs=None, kwargs=None, lineno=1, "
465
+ "keywords=[], lineno=1, "
466
466
"col_offset=0), lineno=1, col_offset=0)])"
467
467
)
468
468
@@ -487,8 +487,7 @@ def test_iter_fields(self):
487
487
node = ast .parse ('foo()' , mode = 'eval' )
488
488
d = dict (ast .iter_fields (node .body ))
489
489
self .assertEqual (d .pop ('func' ).id , 'foo' )
490
- self .assertEqual (d , {'keywords' : [], 'kwargs' : None ,
491
- 'args' : [], 'starargs' : None })
490
+ self .assertEqual (d , {'keywords' : [], 'args' : []})
492
491
493
492
def test_iter_child_nodes (self ):
494
493
node = ast .parse ("spam(23, 42, eggs='leek')" , mode = 'eval' )
@@ -604,8 +603,7 @@ def fac(args):
604
603
self ._check_arguments (fac , self .stmt )
605
604
606
605
def test_classdef (self ):
607
- def cls (bases = None , keywords = None , starargs = None , kwargs = None ,
608
- body = None , decorator_list = None ):
606
+ def cls (bases = None , keywords = None , body = None , decorator_list = None ):
609
607
if bases is None :
610
608
bases = []
611
609
if keywords is None :
@@ -614,16 +612,12 @@ def cls(bases=None, keywords=None, starargs=None, kwargs=None,
614
612
body = [ast .Pass ()]
615
613
if decorator_list is None :
616
614
decorator_list = []
617
- return ast .ClassDef ("myclass" , bases , keywords , starargs ,
618
- kwargs , body , decorator_list )
615
+ return ast .ClassDef ("myclass" , bases , keywords ,
616
+ body , decorator_list )
619
617
self .stmt (cls (bases = [ast .Name ("x" , ast .Store ())]),
620
618
"must have Load context" )
621
619
self .stmt (cls (keywords = [ast .keyword ("x" , ast .Name ("x" , ast .Store ()))]),
622
620
"must have Load context" )
623
- self .stmt (cls (starargs = ast .Name ("x" , ast .Store ())),
624
- "must have Load context" )
625
- self .stmt (cls (kwargs = ast .Name ("x" , ast .Store ())),
626
- "must have Load context" )
627
621
self .stmt (cls (body = []), "empty body on ClassDef" )
628
622
self .stmt (cls (body = [None ]), "None disallowed" )
629
623
self .stmt (cls (decorator_list = [ast .Name ("x" , ast .Store ())]),
@@ -854,20 +848,12 @@ def test_call(self):
854
848
func = ast .Name ("x" , ast .Load ())
855
849
args = [ast .Name ("y" , ast .Load ())]
856
850
keywords = [ast .keyword ("w" , ast .Name ("z" , ast .Load ()))]
857
- stararg = ast .Name ("p" , ast .Load ())
858
- kwarg = ast .Name ("q" , ast .Load ())
859
- call = ast .Call (ast .Name ("x" , ast .Store ()), args , keywords , stararg ,
860
- kwarg )
851
+ call = ast .Call (ast .Name ("x" , ast .Store ()), args , keywords )
861
852
self .expr (call , "must have Load context" )
862
- call = ast .Call (func , [None ], keywords , stararg , kwarg )
853
+ call = ast .Call (func , [None ], keywords )
863
854
self .expr (call , "None disallowed" )
864
855
bad_keywords = [ast .keyword ("w" , ast .Name ("z" , ast .Store ()))]
865
- call = ast .Call (func , args , bad_keywords , stararg , kwarg )
866
- self .expr (call , "must have Load context" )
867
- call = ast .Call (func , args , keywords , ast .Name ("z" , ast .Store ()), kwarg )
868
- self .expr (call , "must have Load context" )
869
- call = ast .Call (func , args , keywords , stararg ,
870
- ast .Name ("w" , ast .Store ()))
856
+ call = ast .Call (func , args , bad_keywords )
871
857
self .expr (call , "must have Load context" )
872
858
873
859
def test_num (self ):
@@ -957,8 +943,8 @@ def main():
957
943
('Module' , [('FunctionDef' , (1 , 0 ), 'f' , ('arguments' , [], ('arg' , (1 , 7 ), 'args' , None ), [], [], None , []), [('Pass' , (1 , 14 ))], [], None )]),
958
944
('Module' , [('FunctionDef' , (1 , 0 ), 'f' , ('arguments' , [], None , [], [], ('arg' , (1 , 8 ), 'kwargs' , None ), []), [('Pass' , (1 , 17 ))], [], None )]),
959
945
('Module' , [('FunctionDef' , (1 , 0 ), 'f' , ('arguments' , [('arg' , (1 , 6 ), 'a' , None ), ('arg' , (1 , 9 ), 'b' , None ), ('arg' , (1 , 14 ), 'c' , None ), ('arg' , (1 , 22 ), 'd' , None ), ('arg' , (1 , 28 ), 'e' , None )], ('arg' , (1 , 35 ), 'args' , None ), [('arg' , (1 , 41 ), 'f' , None )], [('Num' , (1 , 43 ), 42 )], ('arg' , (1 , 49 ), 'kwargs' , None ), [('Num' , (1 , 11 ), 1 ), ('NameConstant' , (1 , 16 ), None ), ('List' , (1 , 24 ), [], ('Load' ,)), ('Dict' , (1 , 30 ), [], [])]), [('Pass' , (1 , 58 ))], [], None )]),
960
- ('Module' , [('ClassDef' , (1 , 0 ), 'C' , [], [], None , None , [('Pass' , (1 , 8 ))], [])]),
961
- ('Module' , [('ClassDef' , (1 , 0 ), 'C' , [('Name' , (1 , 8 ), 'object' , ('Load' ,))], [], None , None , [('Pass' , (1 , 17 ))], [])]),
946
+ ('Module' , [('ClassDef' , (1 , 0 ), 'C' , [], [], [('Pass' , (1 , 8 ))], [])]),
947
+ ('Module' , [('ClassDef' , (1 , 0 ), 'C' , [('Name' , (1 , 8 ), 'object' , ('Load' ,))], [], [('Pass' , (1 , 17 ))], [])]),
962
948
('Module' , [('FunctionDef' , (1 , 0 ), 'f' , ('arguments' , [], None , [], [], None , []), [('Return' , (1 , 8 ), ('Num' , (1 , 15 ), 1 ))], [], None )]),
963
949
('Module' , [('Delete' , (1 , 0 ), [('Name' , (1 , 4 ), 'v' , ('Del' ,))])]),
964
950
('Module' , [('Assign' , (1 , 0 ), [('Name' , (1 , 0 ), 'v' , ('Store' ,))], ('Num' , (1 , 4 ), 1 ))]),
@@ -968,7 +954,7 @@ def main():
968
954
('Module' , [('If' , (1 , 0 ), ('Name' , (1 , 3 ), 'v' , ('Load' ,)), [('Pass' , (1 , 5 ))], [])]),
969
955
('Module' , [('With' , (1 , 0 ), [('withitem' , ('Name' , (1 , 5 ), 'x' , ('Load' ,)), ('Name' , (1 , 10 ), 'y' , ('Store' ,)))], [('Pass' , (1 , 13 ))])]),
970
956
('Module' , [('With' , (1 , 0 ), [('withitem' , ('Name' , (1 , 5 ), 'x' , ('Load' ,)), ('Name' , (1 , 10 ), 'y' , ('Store' ,))), ('withitem' , ('Name' , (1 , 13 ), 'z' , ('Load' ,)), ('Name' , (1 , 18 ), 'q' , ('Store' ,)))], [('Pass' , (1 , 21 ))])]),
971
- ('Module' , [('Raise' , (1 , 0 ), ('Call' , (1 , 6 ), ('Name' , (1 , 6 ), 'Exception' , ('Load' ,)), [('Str' , (1 , 16 ), 'string' )], [], None , None ), None )]),
957
+ ('Module' , [('Raise' , (1 , 0 ), ('Call' , (1 , 6 ), ('Name' , (1 , 6 ), 'Exception' , ('Load' ,)), [('Str' , (1 , 16 ), 'string' )], []), None )]),
972
958
('Module' , [('Try' , (1 , 0 ), [('Pass' , (2 , 2 ))], [('ExceptHandler' , (3 , 0 ), ('Name' , (3 , 7 ), 'Exception' , ('Load' ,)), None , [('Pass' , (4 , 2 ))])], [], [])]),
973
959
('Module' , [('Try' , (1 , 0 ), [('Pass' , (2 , 2 ))], [], [], [('Pass' , (4 , 2 ))])]),
974
960
('Module' , [('Assert' , (1 , 0 ), ('Name' , (1 , 7 ), 'v' , ('Load' ,)), None )]),
@@ -998,14 +984,14 @@ def main():
998
984
('Expression' , ('BinOp' , (1 , 0 ), ('Name' , (1 , 0 ), 'a' , ('Load' ,)), ('Add' ,), ('Name' , (1 , 4 ), 'b' , ('Load' ,)))),
999
985
('Expression' , ('UnaryOp' , (1 , 0 ), ('Not' ,), ('Name' , (1 , 4 ), 'v' , ('Load' ,)))),
1000
986
('Expression' , ('Lambda' , (1 , 0 ), ('arguments' , [], None , [], [], None , []), ('NameConstant' , (1 , 7 ), None ))),
1001
- ('Expression' , ('Dict' , (1 , 0 ), [('Num' , (1 , 2 ), 1 )], [('Num' , (1 , 4 ), 2 )])),
987
+ ('Expression' , ('Dict' , (1 , 2 ), [('Num' , (1 , 2 ), 1 )], [('Num' , (1 , 4 ), 2 )])),
1002
988
('Expression' , ('Dict' , (1 , 0 ), [], [])),
1003
- ('Expression' , ('Set' , (1 , 0 ), [('NameConstant' , (1 , 1 ), None )])),
1004
- ('Expression' , ('Dict' , (1 , 0 ), [('Num' , (2 , 6 ), 1 )], [('Num' , (4 , 10 ), 2 )])),
989
+ ('Expression' , ('Set' , (1 , 1 ), [('NameConstant' , (1 , 1 ), None )])),
990
+ ('Expression' , ('Dict' , (2 , 6 ), [('Num' , (2 , 6 ), 1 )], [('Num' , (4 , 10 ), 2 )])),
1005
991
('Expression' , ('ListComp' , (1 , 1 ), ('Name' , (1 , 1 ), 'a' , ('Load' ,)), [('comprehension' , ('Name' , (1 , 7 ), 'b' , ('Store' ,)), ('Name' , (1 , 12 ), 'c' , ('Load' ,)), [('Name' , (1 , 17 ), 'd' , ('Load' ,))])])),
1006
992
('Expression' , ('GeneratorExp' , (1 , 1 ), ('Name' , (1 , 1 ), 'a' , ('Load' ,)), [('comprehension' , ('Name' , (1 , 7 ), 'b' , ('Store' ,)), ('Name' , (1 , 12 ), 'c' , ('Load' ,)), [('Name' , (1 , 17 ), 'd' , ('Load' ,))])])),
1007
993
('Expression' , ('Compare' , (1 , 0 ), ('Num' , (1 , 0 ), 1 ), [('Lt' ,), ('Lt' ,)], [('Num' , (1 , 4 ), 2 ), ('Num' , (1 , 8 ), 3 )])),
1008
- ('Expression' , ('Call' , (1 , 0 ), ('Name' , (1 , 0 ), 'f' , ('Load' ,)), [('Num' , (1 , 2 ), 1 ), ('Num' , (1 , 4 ), 2 )], [( 'keyword ' , 'c' , ( 'Num ' , (1 , 8 ), 3 )) ], ( 'Name ' , ( 1 , 11 ), 'd' , ('Load' ,)) , ('Name' , (1 , 15 ), 'e' , ('Load' ,)))),
994
+ ('Expression' , ('Call' , (1 , 0 ), ('Name' , (1 , 0 ), 'f' , ('Load' ,)), [('Num' , (1 , 2 ), 1 ), ('Num' , (1 , 4 ), 2 ), ( 'Starred ' , ( 1 , 10 ), ( 'Name ' , (1 , 11 ), 'd' , ( 'Load' ,)), ( 'Load' ,)) ], [( 'keyword ' , 'c' , ( 'Num' , ( 1 , 8 ), 3 )) , ('keyword' , None , ('Name' , (1 , 15 ), 'e' , ('Load' ,)))] )),
1009
995
('Expression' , ('Num' , (1 , 0 ), 10 )),
1010
996
('Expression' , ('Str' , (1 , 0 ), 'string' )),
1011
997
('Expression' , ('Attribute' , (1 , 0 ), ('Name' , (1 , 0 ), 'a' , ('Load' ,)), 'b' , ('Load' ,))),
@@ -1016,6 +1002,6 @@ def main():
1016
1002
('Expression' , ('Tuple' , (1 , 0 ), [('Num' , (1 , 0 ), 1 ), ('Num' , (1 , 2 ), 2 ), ('Num' , (1 , 4 ), 3 )], ('Load' ,))),
1017
1003
('Expression' , ('Tuple' , (1 , 1 ), [('Num' , (1 , 1 ), 1 ), ('Num' , (1 , 3 ), 2 ), ('Num' , (1 , 5 ), 3 )], ('Load' ,))),
1018
1004
('Expression' , ('Tuple' , (1 , 0 ), [], ('Load' ,))),
1019
- ('Expression' , ('Call' , (1 , 0 ), ('Attribute' , (1 , 0 ), ('Attribute' , (1 , 0 ), ('Attribute' , (1 , 0 ), ('Name' , (1 , 0 ), 'a' , ('Load' ,)), 'b' , ('Load' ,)), 'c' , ('Load' ,)), 'd' , ('Load' ,)), [('Subscript' , (1 , 8 ), ('Attribute' , (1 , 8 ), ('Name' , (1 , 8 ), 'a' , ('Load' ,)), 'b' , ('Load' ,)), ('Slice' , ('Num' , (1 , 12 ), 1 ), ('Num' , (1 , 14 ), 2 ), None ), ('Load' ,))], [], None , None )),
1005
+ ('Expression' , ('Call' , (1 , 0 ), ('Attribute' , (1 , 0 ), ('Attribute' , (1 , 0 ), ('Attribute' , (1 , 0 ), ('Name' , (1 , 0 ), 'a' , ('Load' ,)), 'b' , ('Load' ,)), 'c' , ('Load' ,)), 'd' , ('Load' ,)), [('Subscript' , (1 , 8 ), ('Attribute' , (1 , 8 ), ('Name' , (1 , 8 ), 'a' , ('Load' ,)), 'b' , ('Load' ,)), ('Slice' , ('Num' , (1 , 12 ), 1 ), ('Num' , (1 , 14 ), 2 ), None ), ('Load' ,))], [])),
1020
1006
]
1021
1007
main ()
0 commit comments