[Python-checkins] cpython (merge 3.4 -> default): Issue #22823: Use set literals in lib2to3.
serhiy.storchaka
python-checkins at python.org
Sat Dec 13 20:53:17 CET 2014
https://hg.python.org/cpython/rev/d3e43f7ecca8
changeset: 93873:d3e43f7ecca8
parent: 93870:81a56c9e1e1c
parent: 93872:c3f960cff3e6
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sat Dec 13 21:51:17 2014 +0200
summary:
Issue #22823: Use set literals in lib2to3.
files:
Lib/lib2to3/fixer_util.py | 8 ++++----
Lib/lib2to3/fixes/fix_dict.py | 2 +-
Lib/lib2to3/patcomp.py | 2 +-
Lib/lib2to3/refactor.py | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Lib/lib2to3/fixer_util.py b/Lib/lib2to3/fixer_util.py
--- a/Lib/lib2to3/fixer_util.py
+++ b/Lib/lib2to3/fixer_util.py
@@ -187,8 +187,8 @@
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 @@
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 @@
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:
diff --git a/Lib/lib2to3/fixes/fix_dict.py b/Lib/lib2to3/fixes/fix_dict.py
--- a/Lib/lib2to3/fixes/fix_dict.py
+++ b/Lib/lib2to3/fixes/fix_dict.py
@@ -36,7 +36,7 @@
from .. import fixer_util
-iter_exempt = fixer_util.consuming_calls | set(["iter"])
+iter_exempt = fixer_util.consuming_calls | {"iter"}
class FixDict(fixer_base.BaseFix):
diff --git a/Lib/lib2to3/patcomp.py b/Lib/lib2to3/patcomp.py
--- a/Lib/lib2to3/patcomp.py
+++ b/Lib/lib2to3/patcomp.py
@@ -32,7 +32,7 @@
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
diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -57,7 +57,7 @@
# 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 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:
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list