@@ -189,8 +189,8 @@ def _filter_nodes(superclass, all_nodes=_all_nodes):
189
189
# and we don't want `stmt` and friends in their so get only the class whose
190
190
# names are capitalized
191
191
_base_supported_nodes = (_all_node_names - _unsupported_nodes ) | _hacked_nodes
192
- _msg = 'cannot both support and not support {0 }' .format (_unsupported_nodes &
193
- _base_supported_nodes )
192
+ _msg = 'cannot both support and not support {intersection }' .format (
193
+ intersection = _unsupported_nodes & _base_supported_nodes )
194
194
assert not _unsupported_nodes & _base_supported_nodes , _msg
195
195
196
196
@@ -200,8 +200,8 @@ def _node_not_implemented(node_name, cls):
200
200
"""
201
201
202
202
def f (self , * args , ** kwargs ):
203
- raise NotImplementedError ("{0 !r} nodes are not "
204
- "implemented" .format (node_name ))
203
+ raise NotImplementedError ("{name !r} nodes are not "
204
+ "implemented" .format (name = node_name ))
205
205
return f
206
206
207
207
@@ -217,7 +217,7 @@ def disallowed(cls):
217
217
cls .unsupported_nodes = ()
218
218
for node in nodes :
219
219
new_method = _node_not_implemented (node , cls )
220
- name = 'visit_{0 }' .format (node )
220
+ name = 'visit_{node }' .format (node = node )
221
221
cls .unsupported_nodes += (name ,)
222
222
setattr (cls , name , new_method )
223
223
return cls
@@ -251,13 +251,14 @@ def add_ops(op_classes):
251
251
"""Decorator to add default implementation of ops."""
252
252
def f (cls ):
253
253
for op_attr_name , op_class in compat .iteritems (op_classes ):
254
- ops = getattr (cls , '{0}_ops' .format (op_attr_name ))
255
- ops_map = getattr (cls , '{0}_op_nodes_map' .format (op_attr_name ))
254
+ ops = getattr (cls , '{name}_ops' .format (name = op_attr_name ))
255
+ ops_map = getattr (cls , '{name}_op_nodes_map' .format (
256
+ name = op_attr_name ))
256
257
for op in ops :
257
258
op_node = ops_map [op ]
258
259
if op_node is not None :
259
260
made_op = _op_maker (op_class , op )
260
- setattr (cls , 'visit_{0 }' .format (op_node ), made_op )
261
+ setattr (cls , 'visit_{node }' .format (node = op_node ), made_op )
261
262
return cls
262
263
return f
263
264
@@ -388,9 +389,10 @@ def _maybe_evaluate_binop(self, op, op_class, lhs, rhs,
388
389
res = op (lhs , rhs )
389
390
390
391
if res .has_invalid_return_type :
391
- raise TypeError ("unsupported operand type(s) for {0}:"
392
- " '{1}' and '{2}'" .format (res .op , lhs .type ,
393
- rhs .type ))
392
+ raise TypeError ("unsupported operand type(s) for {op}:"
393
+ " '{lhs}' and '{rhs}'" .format (op = res .op ,
394
+ lhs = lhs .type ,
395
+ rhs = rhs .type ))
394
396
395
397
if self .engine != 'pytables' :
396
398
if (res .op in _cmp_ops_syms and
@@ -527,7 +529,8 @@ def visit_Attribute(self, node, **kwargs):
527
529
if isinstance (value , ast .Name ) and value .id == attr :
528
530
return resolved
529
531
530
- raise ValueError ("Invalid Attribute context {0}" .format (ctx .__name__ ))
532
+ raise ValueError ("Invalid Attribute context {name}"
533
+ .format (name = ctx .__name__ ))
531
534
532
535
def visit_Call_35 (self , node , side = None , ** kwargs ):
533
536
""" in 3.5 the starargs attribute was changed to be more flexible,
@@ -549,7 +552,8 @@ def visit_Call_35(self, node, side=None, **kwargs):
549
552
raise
550
553
551
554
if res is None :
552
- raise ValueError ("Invalid function call {0}" .format (node .func .id ))
555
+ raise ValueError ("Invalid function call {func}"
556
+ .format (func = node .func .id ))
553
557
if hasattr (res , 'value' ):
554
558
res = res .value
555
559
@@ -558,8 +562,8 @@ def visit_Call_35(self, node, side=None, **kwargs):
558
562
new_args = [self .visit (arg ) for arg in node .args ]
559
563
560
564
if node .keywords :
561
- raise TypeError ("Function \" {0 }\" does not support keyword "
562
- "arguments" .format (res .name ))
565
+ raise TypeError ("Function \" {name }\" does not support keyword "
566
+ "arguments" .format (name = res .name ))
563
567
564
568
return res (* new_args , ** kwargs )
565
569
@@ -570,7 +574,7 @@ def visit_Call_35(self, node, side=None, **kwargs):
570
574
for key in node .keywords :
571
575
if not isinstance (key , ast .keyword ):
572
576
raise ValueError ("keyword error in function call "
573
- "'{0 }'" .format (node .func .id ))
577
+ "'{func }'" .format (func = node .func .id ))
574
578
575
579
if key .arg :
576
580
# TODO: bug?
@@ -598,7 +602,8 @@ def visit_Call_legacy(self, node, side=None, **kwargs):
598
602
raise
599
603
600
604
if res is None :
601
- raise ValueError ("Invalid function call {0}" .format (node .func .id ))
605
+ raise ValueError ("Invalid function call {func}"
606
+ .format (func = node .func .id ))
602
607
if hasattr (res , 'value' ):
603
608
res = res .value
604
609
@@ -609,8 +614,8 @@ def visit_Call_legacy(self, node, side=None, **kwargs):
609
614
args += self .visit (node .starargs )
610
615
611
616
if node .keywords or node .kwargs :
612
- raise TypeError ("Function \" {0 }\" does not support keyword "
613
- "arguments" .format (res .name ))
617
+ raise TypeError ("Function \" {name }\" does not support keyword "
618
+ "arguments" .format (name = res .name ))
614
619
615
620
return res (* args , ** kwargs )
616
621
@@ -623,7 +628,7 @@ def visit_Call_legacy(self, node, side=None, **kwargs):
623
628
for key in node .keywords :
624
629
if not isinstance (key , ast .keyword ):
625
630
raise ValueError ("keyword error in function call "
626
- "'{0 }'" .format (node .func .id ))
631
+ "'{func }'" .format (func = node .func .id ))
627
632
keywords [key .arg ] = self .visit (key .value ).value
628
633
if node .kwargs is not None :
629
634
keywords .update (self .visit (node .kwargs ).value )
0 commit comments