Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 050ca65

Browse files
Issue #22823: Use set literals in lib2to3.
2 parents e0f4bc7 + db9b65d commit 050ca65

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

Lib/lib2to3/fixer_util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ def parenthesize(node):
187187
return Node(syms.atom, [LParen(), node, RParen()])
188188

189189

190-
consuming_calls = set(["sorted", "list", "set", "any", "all", "tuple", "sum",
191-
"min", "max", "enumerate"])
190+
consuming_calls = {"sorted", "list", "set", "any", "all", "tuple", "sum",
191+
"min", "max", "enumerate"}
192192

193193
def attr_chain(obj, attr):
194194
"""Follow an attribute chain.
@@ -359,7 +359,7 @@ def is_import_stmt(node):
359359
root.insert_child(insert_pos, Node(syms.simple_stmt, children))
360360

361361

362-
_def_syms = set([syms.classdef, syms.funcdef])
362+
_def_syms = {syms.classdef, syms.funcdef}
363363
def find_binding(name, node, package=None):
364364
""" Returns the node which binds variable name, otherwise None.
365365
If optional argument package is supplied, only imports will
@@ -402,7 +402,7 @@ def find_binding(name, node, package=None):
402402
return ret
403403
return None
404404

405-
_block_syms = set([syms.funcdef, syms.classdef, syms.trailer])
405+
_block_syms = {syms.funcdef, syms.classdef, syms.trailer}
406406
def _find(name, node):
407407
nodes = [node]
408408
while nodes:

Lib/lib2to3/fixes/fix_dict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from .. import fixer_util
3737

3838

39-
iter_exempt = fixer_util.consuming_calls | set(["iter"])
39+
iter_exempt = fixer_util.consuming_calls | {"iter"}
4040

4141

4242
class FixDict(fixer_base.BaseFix):

Lib/lib2to3/patcomp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PatternSyntaxError(Exception):
3232

3333
def tokenize_wrapper(input):
3434
"""Tokenizes a string suppressing significant whitespace."""
35-
skip = set((token.NEWLINE, token.INDENT, token.DEDENT))
35+
skip = {token.NEWLINE, token.INDENT, token.DEDENT}
3636
tokens = tokenize.generate_tokens(io.StringIO(input).readline)
3737
for quintuple in tokens:
3838
type, value, start, end, line_text = quintuple

Lib/lib2to3/refactor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _get_head_types(pat):
5757
# Always return leafs
5858
if pat.type is None:
5959
raise _EveryNode
60-
return set([pat.type])
60+
return {pat.type}
6161

6262
if isinstance(pat, pytree.NegatedPattern):
6363
if pat.content:
@@ -133,7 +133,7 @@ def _detect_future_features(source):
133133
def advance():
134134
tok = next(gen)
135135
return tok[0], tok[1]
136-
ignore = frozenset((token.NEWLINE, tokenize.NL, token.COMMENT))
136+
ignore = frozenset({token.NEWLINE, tokenize.NL, token.COMMENT})
137137
features = set()
138138
try:
139139
while True:

0 commit comments

Comments
 (0)