@@ -189,8 +189,8 @@ def _filter_nodes(superclass, all_nodes=_all_nodes):
189189# and we don't want `stmt` and friends in their so get only the class whose
190190# names are capitalized
191191_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 )
194194assert not _unsupported_nodes & _base_supported_nodes , _msg
195195
196196
@@ -200,8 +200,8 @@ def _node_not_implemented(node_name, cls):
200200 """
201201
202202 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 ))
205205 return f
206206
207207
@@ -217,7 +217,7 @@ def disallowed(cls):
217217 cls .unsupported_nodes = ()
218218 for node in nodes :
219219 new_method = _node_not_implemented (node , cls )
220- name = 'visit_{0 }' .format (node )
220+ name = 'visit_{node }' .format (node = node )
221221 cls .unsupported_nodes += (name ,)
222222 setattr (cls , name , new_method )
223223 return cls
@@ -251,13 +251,14 @@ def add_ops(op_classes):
251251 """Decorator to add default implementation of ops."""
252252 def f (cls ):
253253 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 ))
256257 for op in ops :
257258 op_node = ops_map [op ]
258259 if op_node is not None :
259260 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 )
261262 return cls
262263 return f
263264
@@ -388,9 +389,10 @@ def _maybe_evaluate_binop(self, op, op_class, lhs, rhs,
388389 res = op (lhs , rhs )
389390
390391 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 ))
394396
395397 if self .engine != 'pytables' :
396398 if (res .op in _cmp_ops_syms and
@@ -527,7 +529,8 @@ def visit_Attribute(self, node, **kwargs):
527529 if isinstance (value , ast .Name ) and value .id == attr :
528530 return resolved
529531
530- raise ValueError ("Invalid Attribute context {0}" .format (ctx .__name__ ))
532+ raise ValueError ("Invalid Attribute context {name}"
533+ .format (name = ctx .__name__ ))
531534
532535 def visit_Call_35 (self , node , side = None , ** kwargs ):
533536 """ 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):
549552 raise
550553
551554 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 ))
553557 if hasattr (res , 'value' ):
554558 res = res .value
555559
@@ -558,8 +562,8 @@ def visit_Call_35(self, node, side=None, **kwargs):
558562 new_args = [self .visit (arg ) for arg in node .args ]
559563
560564 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 ))
563567
564568 return res (* new_args , ** kwargs )
565569
@@ -570,7 +574,7 @@ def visit_Call_35(self, node, side=None, **kwargs):
570574 for key in node .keywords :
571575 if not isinstance (key , ast .keyword ):
572576 raise ValueError ("keyword error in function call "
573- "'{0 }'" .format (node .func .id ))
577+ "'{func }'" .format (func = node .func .id ))
574578
575579 if key .arg :
576580 # TODO: bug?
@@ -598,7 +602,8 @@ def visit_Call_legacy(self, node, side=None, **kwargs):
598602 raise
599603
600604 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 ))
602607 if hasattr (res , 'value' ):
603608 res = res .value
604609
@@ -609,8 +614,8 @@ def visit_Call_legacy(self, node, side=None, **kwargs):
609614 args += self .visit (node .starargs )
610615
611616 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 ))
614619
615620 return res (* args , ** kwargs )
616621
@@ -623,7 +628,7 @@ def visit_Call_legacy(self, node, side=None, **kwargs):
623628 for key in node .keywords :
624629 if not isinstance (key , ast .keyword ):
625630 raise ValueError ("keyword error in function call "
626- "'{0 }'" .format (node .func .id ))
631+ "'{func }'" .format (func = node .func .id ))
627632 keywords [key .arg ] = self .visit (key .value ).value
628633 if node .kwargs is not None :
629634 keywords .update (self .visit (node .kwargs ).value )
0 commit comments