Skip to content

Commit cf8f93b

Browse files
committed
Set literals
1 parent fb8fc68 commit cf8f93b

File tree

20 files changed

+36
-45
lines changed

20 files changed

+36
-45
lines changed

source_py2/python_toolbox/arguments_profile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ def __init__(self, function, *args, **kwargs):
161161
# `dict` that maps from argument name to default value:
162162
defaults = OrderedDict(zip(defaultful_args, s_defaults))
163163

164-
defaultful_args_differing_from_defaults = set((
164+
defaultful_args_differing_from_defaults = {
165165
defaultful_arg for defaultful_arg in defaultful_args
166166
if defaults[defaultful_arg] != getcallargs_result[defaultful_arg]
167-
))
167+
}
168168

169169
if s_star_args and getcallargs_result[s_star_args]:
170170
# We have some arguments that go into `*args`! This means that we

source_py2/python_toolbox/dict_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def reverse_with_set_values(d, sort=False):
7070
Example:
7171
7272
reverse_with_set_values({1: 2, 3: 4, 'meow': 2}) == \
73-
{2: set([1, 'meow']), 4: set([3])}
73+
{2: {1, 'meow'}, 4: {3}}
7474
7575
Instead of a dict you may also input a tuple in which the first item is an
7676
iterable and the second item is either a key function or an attribute name.

source_py2/python_toolbox/emitting/emitter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ def _get_callable_outputs(self):
240240

241241
def _get_emitter_outputs(self):
242242
'''Get the direct emitter outputs of this emitter.'''
243-
return set((
244-
output for output in self._outputs if isinstance(output, Emitter)
245-
))
243+
return {output for output in self._outputs if isinstance(output, Emitter)}
246244

247245
def get_total_callable_outputs(self):
248246
'''

source_py2/python_toolbox/misc_tools/name_mangling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def mangle_attribute_name_if_needed(attribute_name, class_name):
1414
if ((not attribute_name.startswith('__')) or
1515
(len(attribute_name) + 2 >= MANGLE_LEN) or
1616
(attribute_name.endswith('__')) or
17-
set(class_name) == set('_')):
17+
set(class_name) == {'_'}):
1818

1919
return attribute_name
2020

source_py2/test_python_toolbox/test_arguments_profile.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ def func(a, b, c=3, d=4, **kwargs):
459459
assert not a1.kwargs
460460
hash(a1)
461461

462-
a2 = ArgumentsProfile(func, 7, ({'a': 'b'},), set([1, (3, 4)]),
462+
a2 = ArgumentsProfile(func, 7, ({'a': 'b'},), {1, (3, 4)},
463463
meow=[1, 2, {1: [1, 2]}])
464-
assert a2.args == (7, ({'a': 'b'},), set([1, (3, 4)]))
464+
assert a2.args == (7, ({'a': 'b'},), {1, (3, 4)})
465465
assert a2.kwargs == OrderedDict(
466466
(('meow', [1, 2, {1: [1, 2]}]),)
467467
)
@@ -477,17 +477,17 @@ def test_unhashable_star_empty():
477477
def func(a, b, c=3, d=4, **kwargs):
478478
pass
479479

480-
a2 = ArgumentsProfile(func, 7, ({'a': 'b'},), set([1, (3, 4)]),
480+
a2 = ArgumentsProfile(func, 7, ({'a': 'b'},), {1, (3, 4)},
481481
meow=[1, 2, {1: [1, 2]}])
482-
assert a2.args == (7, ({'a': 'b'},), set([1, (3, 4)]))
482+
assert a2.args == (7, ({'a': 'b'},), {1, (3, 4)})
483483
assert a2.kwargs == OrderedDict(
484484
(('meow', [1, 2, {1: [1, 2]}]),)
485485
)
486486

487487
a3 = ArgumentsProfile(func, *(), b=({'a': 'b'},),
488-
c=set([1, (3, 4)]), a=7,
488+
c={1, (3, 4)}, a=7,
489489
meow=[1, 2, {1: [1, 2]}])
490-
assert a3.args == (7, ({'a': 'b'},), set([1, (3, 4)]))
490+
assert a3.args == (7, ({'a': 'b'},), {1, (3, 4)})
491491
assert a3.kwargs == OrderedDict(
492492
(('meow', [1, 2, {1: [1, 2]}]),)
493493
)

source_py2/test_python_toolbox/test_caching/test_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_unhashable_arguments():
114114

115115
f = cache()(counting_func)
116116

117-
x = set((1, 2))
117+
x = {1, 2}
118118

119119
assert f(x) == f(x)
120120

source_py2/test_python_toolbox/test_cheat_hashing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_cheat_hash():
1818
[1, 2, 3.4],
1919
(1, 2, 3.4),
2020
{1: 2, 3: 4.5},
21-
set((1, 2, 3.4)),
21+
{1, 2, 3.4},
2222
[1, [1, 2], 3],
2323
[1, {frozenset((1, 2)): 'meow'}, 3],
2424
sum,

source_py2/test_python_toolbox/test_context_management/test_reentrant_context_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def reentrant_exit(self, exc_type, exc_value, exc_traceback):
109109
my_set.add(6)
110110
my_set.add(7)
111111
my_set.add(8)
112-
assert my_set == set([0, 1, 2, 3, 4])
112+
assert my_set == {0, 1, 2, 3, 4}
113113

114114

115115

source_py2/test_python_toolbox/test_cute_profile/test_cute_profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
def func(x, y, z=3):
1919
'''Function that does some meaningless number-juggling.'''
2020
sum([1, 2, 3])
21-
set([1, 2]) | set([2, 3])
21+
{1, 2} | {2, 3}
2222
return x, y, z
2323

2424

source_py2/test_python_toolbox/test_dict_tools/test_devour_items.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
def test():
1010
'''Test the basic workings of `devour_items`.'''
1111
my_dict = {1: 2, 3: 4, 5: 6,}
12-
assert set(dict_tools.devour_items(my_dict)) == set(((1, 2), (3, 4),
13-
(5, 6)))
12+
assert set(dict_tools.devour_items(my_dict)) == {(1, 2), (3, 4), (5, 6)}
1413
assert not my_dict
1514

0 commit comments

Comments
 (0)