diff -r fc7dbba57869 Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst Sun Nov 09 20:48:36 2014 +0200 +++ b/Doc/howto/logging-cookbook.rst Sun Nov 09 23:09:59 2014 +0200 @@ -1680,7 +1680,7 @@ as in the following complete example:: def main(): logging.basicConfig(level=logging.INFO, format='%(message)s') - logging.info(_('message 1', set_value=set([1, 2, 3]), snowman='\u2603')) + logging.info(_('message 1', set_value={1, 2, 3}, snowman='\u2603')) if __name__ == '__main__': main() diff -r fc7dbba57869 Doc/library/pickle.rst --- a/Doc/library/pickle.rst Sun Nov 09 20:48:36 2014 +0200 +++ b/Doc/library/pickle.rst Sun Nov 09 23:09:59 2014 +0200 @@ -859,7 +859,7 @@ For the simplest code, use the :func:`du data = { 'a': [1, 2.0, 3, 4+6j], 'b': ("character string", b"byte string"), - 'c': set([None, True, False]) + 'c': {None, True, False} } with open('data.pickle', 'wb') as f: diff -r fc7dbba57869 Doc/library/unittest.mock-examples.rst --- a/Doc/library/unittest.mock-examples.rst Sun Nov 09 20:48:36 2014 +0200 +++ b/Doc/library/unittest.mock-examples.rst Sun Nov 09 23:09:59 2014 +0200 @@ -756,16 +756,16 @@ When we try to test that ``grob`` calls what happens: >>> with patch('mymodule.frob') as mock_frob: - ... val = set([6]) + ... val = {6} ... mymodule.grob(val) ... >>> val - set([]) - >>> mock_frob.assert_called_with(set([6])) + set() + >>> mock_frob.assert_called_with({6}) Traceback (most recent call last): ... - AssertionError: Expected: ((set([6]),), {}) - Called with: ((set([]),), {}) + AssertionError: Expected: (({6},), {}) + Called with: ((set(),), {}) One possibility would be for mock to copy the arguments you pass in. This could then cause problems if you do assertions that rely on object identity @@ -793,12 +793,12 @@ me. ... >>> with patch('mymodule.frob') as mock_frob: ... new_mock = copy_call_args(mock_frob) - ... val = set([6]) + ... val = {6} ... mymodule.grob(val) ... - >>> new_mock.assert_called_with(set([6])) + >>> new_mock.assert_called_with({6}) >>> new_mock.call_args - call(set([6])) + call({6}) ``copy_call_args`` is called with the mock that will be called. It returns a new mock that we do the assertion on. The ``side_effect`` function makes a copy of @@ -811,10 +811,10 @@ the args and calls our ``new_mock`` with checking inside a ``side_effect`` function. >>> def side_effect(arg): - ... assert arg == set([6]) + ... assert arg == {6} ... >>> mock = Mock(side_effect=side_effect) - >>> mock(set([6])) + >>> mock({6}) >>> mock(set()) Traceback (most recent call last): ... @@ -839,8 +839,8 @@ Here's an example implementation: >>> c.assert_called_with(arg) Traceback (most recent call last): ... - AssertionError: Expected call: mock(set([1])) - Actual call: mock(set([])) + AssertionError: Expected call: mock({1}) + Actual call: mock(set()) >>> c.foo diff -r fc7dbba57869 Lib/_strptime.py --- a/Lib/_strptime.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/_strptime.py Sun Nov 09 23:09:59 2014 +0200 @@ -167,9 +167,9 @@ class LocaleTime(object): time.tzset() except AttributeError: pass - no_saving = frozenset(["utc", "gmt", time.tzname[0].lower()]) + no_saving = frozenset({"utc", "gmt", time.tzname[0].lower()}) if time.daylight: - has_saving = frozenset([time.tzname[1].lower()]) + has_saving = frozenset({time.tzname[1].lower()}) else: has_saving = frozenset() self.timezone = (no_saving, has_saving) diff -r fc7dbba57869 Lib/asyncore.py --- a/Lib/asyncore.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/asyncore.py Sun Nov 09 23:09:59 2014 +0200 @@ -57,8 +57,8 @@ from errno import EALREADY, EINPROGRESS, ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \ errorcode -_DISCONNECTED = frozenset((ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE, - EBADF)) +_DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE, + EBADF}) try: socket_map @@ -220,7 +220,7 @@ class dispatcher: connecting = False closing = False addr = None - ignore_log_types = frozenset(['warning']) + ignore_log_types = frozenset({'warning'}) def __init__(self, sock=None, map=None): if map is None: diff -r fc7dbba57869 Lib/distutils/msvc9compiler.py --- a/Lib/distutils/msvc9compiler.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/distutils/msvc9compiler.py Sun Nov 09 23:09:59 2014 +0200 @@ -252,7 +252,7 @@ def query_vcvarsall(version, arch="x86") """Launch vcvarsall.bat and read the settings from its environment """ vcvarsall = find_vcvarsall(version) - interesting = set(("include", "lib", "libpath", "path")) + interesting = {"include", "lib", "libpath", "path"} result = {} if vcvarsall is None: diff -r fc7dbba57869 Lib/idlelib/CodeContext.py --- a/Lib/idlelib/CodeContext.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/idlelib/CodeContext.py Sun Nov 09 23:09:59 2014 +0200 @@ -15,8 +15,8 @@ import re from sys import maxsize as INFINITY from idlelib.configHandler import idleConf -BLOCKOPENERS = set(["class", "def", "elif", "else", "except", "finally", "for", - "if", "try", "while", "with"]) +BLOCKOPENERS = {"class", "def", "elif", "else", "except", "finally", "for", + "if", "try", "while", "with"} UPDATEINTERVAL = 100 # millisec FONTUPDATEINTERVAL = 1000 # millisec diff -r fc7dbba57869 Lib/ipaddress.py --- a/Lib/ipaddress.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/ipaddress.py Sun Nov 09 23:09:59 2014 +0200 @@ -1088,7 +1088,7 @@ class _BaseV4: _DECIMAL_DIGITS = frozenset('0123456789') # the valid octets for host and netmasks. only useful for IPv4. - _valid_mask_octets = frozenset((255, 254, 252, 248, 240, 224, 192, 128, 0)) + _valid_mask_octets = frozenset({255, 254, 252, 248, 240, 224, 192, 128, 0}) _max_prefixlen = IPV4LENGTH # There are only a handful of valid v4 netmasks, so we cache them all diff -r fc7dbba57869 Lib/lib2to3/fixer_util.py --- a/Lib/lib2to3/fixer_util.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/lib2to3/fixer_util.py Sun Nov 09 23:09:59 2014 +0200 @@ -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=Non 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 -r fc7dbba57869 Lib/lib2to3/fixes/fix_dict.py --- a/Lib/lib2to3/fixes/fix_dict.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/lib2to3/fixes/fix_dict.py Sun Nov 09 23:09:59 2014 +0200 @@ -36,7 +36,7 @@ from ..fixer_util import Name, Call, LPa 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 -r fc7dbba57869 Lib/lib2to3/patcomp.py --- a/Lib/lib2to3/patcomp.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/lib2to3/patcomp.py Sun Nov 09 23:09:59 2014 +0200 @@ -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 diff -r fc7dbba57869 Lib/lib2to3/refactor.py --- a/Lib/lib2to3/refactor.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/lib2to3/refactor.py Sun Nov 09 23:09:59 2014 +0200 @@ -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: diff -r fc7dbba57869 Lib/mailbox.py --- a/Lib/mailbox.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/mailbox.py Sun Nov 09 23:09:59 2014 +0200 @@ -1230,8 +1230,8 @@ class MH(Mailbox): class Babyl(_singlefileMailbox): """An Rmail-style Babyl mailbox.""" - _special_labels = frozenset(('unseen', 'deleted', 'filed', 'answered', - 'forwarded', 'edited', 'resent')) + _special_labels = frozenset({'unseen', 'deleted', 'filed', 'answered', + 'forwarded', 'edited', 'resent'}) def __init__(self, path, factory=None, create=True): """Initialize a Babyl mailbox.""" diff -r fc7dbba57869 Lib/sre_compile.py --- a/Lib/sre_compile.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/sre_compile.py Sun Nov 09 23:09:59 2014 +0200 @@ -21,10 +21,10 @@ if _sre.CODESIZE == 2: else: MAXCODE = 0xFFFFFFFF -_LITERAL_CODES = set([LITERAL, NOT_LITERAL]) -_REPEATING_CODES = set([REPEAT, MIN_REPEAT, MAX_REPEAT]) -_SUCCESS_CODES = set([SUCCESS, FAILURE]) -_ASSERT_CODES = set([ASSERT, ASSERT_NOT]) +_LITERAL_CODES = {LITERAL, NOT_LITERAL} +_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT} +_SUCCESS_CODES = {SUCCESS, FAILURE} +_ASSERT_CODES = {ASSERT, ASSERT_NOT} def _compile(code, pattern, flags): # internal: compile a (sub)pattern diff -r fc7dbba57869 Lib/sre_parse.py --- a/Lib/sre_parse.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/sre_parse.py Sun Nov 09 23:09:59 2014 +0200 @@ -24,8 +24,8 @@ HEXDIGITS = frozenset("0123456789abcdefA WHITESPACE = frozenset(" \t\n\r\v\f") -_REPEATCODES = frozenset((MIN_REPEAT, MAX_REPEAT)) -_UNITCODES = frozenset((ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY)) +_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT}) +_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY}) ESCAPES = { r"\a": (LITERAL, ord("\a")), diff -r fc7dbba57869 Lib/statistics.py --- a/Lib/statistics.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/statistics.py Sun Nov 09 23:09:59 2014 +0200 @@ -150,7 +150,7 @@ def _sum(data, start=0): # We fail as soon as we reach a value that is not an int or the type of # the first value which is not an int. E.g. _sum([int, int, float, int]) # is okay, but sum([int, int, float, Fraction]) is not. - allowed_types = set([int, type(start)]) + allowed_types = {int, type(start)} n, d = _exact_ratio(start) partials = {d: n} # map {denominator: sum of numerators} # Micro-optimizations. @@ -168,7 +168,7 @@ def _sum(data, start=0): assert allowed_types.pop() is int T = int else: - T = (allowed_types - set([int])).pop() + T = (allowed_types - {int}).pop() if None in partials: assert issubclass(T, (float, Decimal)) assert not math.isfinite(partials[None]) diff -r fc7dbba57869 Lib/unittest/mock.py --- a/Lib/unittest/mock.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Lib/unittest/mock.py Sun Nov 09 23:09:59 2014 +0200 @@ -275,13 +275,11 @@ def _copy(value): return value -_allowed_names = set( - [ - 'return_value', '_mock_return_value', 'side_effect', - '_mock_side_effect', '_mock_parent', '_mock_new_parent', - '_mock_name', '_mock_new_name' - ] -) +_allowed_names = { + 'return_value', '_mock_return_value', 'side_effect', + '_mock_side_effect', '_mock_parent', '_mock_new_parent', + '_mock_name', '_mock_new_name' +} def _delegating_property(name): @@ -1701,12 +1699,12 @@ def _get_method(name, func): _all_magics = _magics | _non_defaults -_unsupported_magics = set([ +_unsupported_magics = { '__getattr__', '__setattr__', '__init__', '__new__', '__prepare__' '__instancecheck__', '__subclasscheck__', '__del__' -]) +} _calculate_return_value = { '__hash__': lambda self: object.__hash__(self), diff -r fc7dbba57869 Parser/asdl.py --- a/Parser/asdl.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Parser/asdl.py Sun Nov 09 23:09:59 2014 +0200 @@ -33,8 +33,7 @@ import re # See the EBNF at the top of the file to understand the logical connection # between the various node types. -builtin_types = set( - ['identifier', 'string', 'bytes', 'int', 'object', 'singleton']) +builtin_types = {'identifier', 'string', 'bytes', 'int', 'object', 'singleton'} class AST: def __repr__(self): diff -r fc7dbba57869 Tools/clinic/clinic.py --- a/Tools/clinic/clinic.py Sun Nov 09 20:48:36 2014 +0200 +++ b/Tools/clinic/clinic.py Sun Nov 09 23:09:59 2014 +0200 @@ -2535,9 +2535,9 @@ class str_converter(CConverter): length=False, nullable=False, zeroes=False): types = set(types.strip().split()) - bytes_type = set(("bytes",)) - str_type = set(("str",)) - all_3_type = set(("bytearray",)) | bytes_type | str_type + bytes_type = {"bytes"} + str_type = {"str"} + all_3_type = {"bytearray"} | bytes_type | str_type is_bytes = types == bytes_type is_str = types == str_type is_all_3 = types == all_3_type @@ -2633,12 +2633,12 @@ class Py_buffer_converter(CConverter): fail("The only legal default value for Py_buffer is None.") self.c_default = self.c_ignored_default types = set(types.strip().split()) - bytes_type = set(('bytes',)) - bytearray_type = set(('bytearray',)) - buffer_type = set(('buffer',)) - rwbuffer_type = set(('rwbuffer',)) - robuffer_type = set(('robuffer',)) - str_type = set(('str',)) + bytes_type = {'bytes'} + bytearray_type = {'bytearray'} + buffer_type = {'buffer'} + rwbuffer_type = {'rwbuffer'} + robuffer_type = {'robuffer'} + str_type = {'str'} bytes_bytearray_buffer_type = bytes_type | bytearray_type | buffer_type format_unit = None