]> granicus.if.org Git - python/commitdiff
Issue #22823: Use set literals in lib2to3.
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 13 Dec 2014 19:50:49 +0000 (21:50 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 13 Dec 2014 19:50:49 +0000 (21:50 +0200)
Lib/lib2to3/fixer_util.py
Lib/lib2to3/fixes/fix_dict.py
Lib/lib2to3/patcomp.py
Lib/lib2to3/refactor.py

index 6e259c54ac470e1bf688ce28d916d91f20a0c912..44502bf7bdbd48b752ae0e10e92622f600536cd3 100644 (file)
@@ -187,8 +187,8 @@ def parenthesize(node):
     return Node(syms.atom, [LParen(), node, RParen()])
 
 
-consuming_calls = set(["sorted", "list", "set", "any", "all", "tuple", "sum",
-                       "min", "max", "enumerate"])
+consuming_calls = {"sorted", "list", "set", "any", "all", "tuple", "sum",
+                   "min", "max", "enumerate"}
 
 def attr_chain(obj, attr):
     """Follow an attribute chain.
@@ -359,7 +359,7 @@ def touch_import(package, name, node):
     root.insert_child(insert_pos, Node(syms.simple_stmt, children))
 
 
-_def_syms = set([syms.classdef, syms.funcdef])
+_def_syms = {syms.classdef, syms.funcdef}
 def find_binding(name, node, package=None):
     """ Returns the node which binds variable name, otherwise None.
         If optional argument package is supplied, only imports will
@@ -402,7 +402,7 @@ def find_binding(name, node, package=None):
                 return ret
     return None
 
-_block_syms = set([syms.funcdef, syms.classdef, syms.trailer])
+_block_syms = {syms.funcdef, syms.classdef, syms.trailer}
 def _find(name, node):
     nodes = [node]
     while nodes:
index 4cc37174cb7f2953a46a92d2b62818303fd5777d..963f952e0b04221eedc983df3a9fd359fcc0c9d1 100644 (file)
@@ -36,7 +36,7 @@ from ..fixer_util import Name, Call, LParen, RParen, ArgList, Dot
 from .. import fixer_util
 
 
-iter_exempt = fixer_util.consuming_calls | set(["iter"])
+iter_exempt = fixer_util.consuming_calls | {"iter"}
 
 
 class FixDict(fixer_base.BaseFix):
index 0a259e90afd83844c1311de5e2f379e88af05e61..2012ec4855f14a66ce6262352f538dff9fb82a84 100644 (file)
@@ -32,7 +32,7 @@ class PatternSyntaxError(Exception):
 
 def tokenize_wrapper(input):
     """Tokenizes a string suppressing significant whitespace."""
-    skip = set((token.NEWLINE, token.INDENT, token.DEDENT))
+    skip = {token.NEWLINE, token.INDENT, token.DEDENT}
     tokens = tokenize.generate_tokens(io.StringIO(input).readline)
     for quintuple in tokens:
         type, value, start, end, line_text = quintuple
index 81003178715037a61fd3851abdc510973cae2ed3..c24be14867f09566be69469d6c523a9bd2c79793 100644 (file)
@@ -57,7 +57,7 @@ def _get_head_types(pat):
         # Always return leafs
         if pat.type is None:
             raise _EveryNode
-        return set([pat.type])
+        return {pat.type}
 
     if isinstance(pat, pytree.NegatedPattern):
         if pat.content:
@@ -133,7 +133,7 @@ def _detect_future_features(source):
     def advance():
         tok = next(gen)
         return tok[0], tok[1]
-    ignore = frozenset((token.NEWLINE, tokenize.NL, token.COMMENT))
+    ignore = frozenset({token.NEWLINE, tokenize.NL, token.COMMENT})
     features = set()
     try:
         while True: