diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 13b333e..91b7c9f 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -3178,7 +3178,7 @@ class InteractiveShell(SingletonConfigurable): ns = {} import_pylab(ns, import_all) # warn about clobbered names - ignored = set(["__builtins__"]) + ignored = {"__builtins__"} both = set(ns).intersection(self.user_ns).difference(ignored) clobbered = [ name for name in both if self.user_ns[name] is not ns[name] ] self.user_ns.update(ns) diff --git a/IPython/core/tests/test_completerlib.py b/IPython/core/tests/test_completerlib.py index 494bdb2..9cc4609 100644 --- a/IPython/core/tests/test_completerlib.py +++ b/IPython/core/tests/test_completerlib.py @@ -63,7 +63,7 @@ class Test_magic_run_completer(unittest.TestCase): event = MockEvent(u"%run aa") mockself = None match = set(magic_run_completer(mockself, event)) - self.assertEqual(match, set([u"aao.py"])) + self.assertEqual(match, {u"aao.py"}) def test_3(self): """Test magic_run_completer with unterminated " """ @@ -109,7 +109,7 @@ class Test_magic_run_completer_nonascii(unittest.TestCase): event = MockEvent(u"%run a") mockself = None match = set(magic_run_completer(mockself, event)) - self.assertEqual(match, set([u"a.py", u"aaø.py"])) + self.assertEqual(match, {u"a.py", u"aaø.py"}) @onlyif_unicode_paths def test_2(self): @@ -118,7 +118,7 @@ class Test_magic_run_completer_nonascii(unittest.TestCase): event = MockEvent(u"%run aa") mockself = None match = set(magic_run_completer(mockself, event)) - self.assertEqual(match, set([u"aaø.py"])) + self.assertEqual(match, {u"aaø.py"}) @onlyif_unicode_paths def test_3(self): @@ -126,14 +126,14 @@ class Test_magic_run_completer_nonascii(unittest.TestCase): event = MockEvent(u'%run "a') mockself = None match = set(magic_run_completer(mockself, event)) - self.assertEqual(match, set([u"a.py", u"aaø.py"])) + self.assertEqual(match, {u"a.py", u"aaø.py"}) # module_completer: def test_import_invalid_module(): """Testing of issue https://github.com/ipython/ipython/issues/1107""" - invalid_module_names = set(['foo-bar', 'foo:bar', '10foo']) - valid_module_names = set(['foobar']) + invalid_module_names = {'foo-bar', 'foo:bar', '10foo'} + valid_module_names = {'foobar'} with TemporaryDirectory() as tmpdir: sys.path.insert( 0, tmpdir ) for name in invalid_module_names | valid_module_names: diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index 2f43329..ed2b53f 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -645,12 +645,12 @@ class TestAstTransform(unittest.TestCase): with tt.AssertPrints("best of "): ip.run_line_magic("timeit", "-n1 f(1)") - self.assertEqual(called, set([-1])) + self.assertEqual(called, {-1}) called.clear() with tt.AssertPrints("best of "): ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") - self.assertEqual(called, set([-2, -3])) + self.assertEqual(called, {-2, -3}) def test_time(self): called = [] @@ -718,12 +718,12 @@ class TestAstTransform2(unittest.TestCase): with tt.AssertPrints("best of "): ip.run_line_magic("timeit", "-n1 f(1)") - self.assertEqual(called, set([(1,)])) + self.assertEqual(called, {(1,)}) called.clear() with tt.AssertPrints("best of "): ip.run_cell_magic("timeit", "-n1 f(2)", "f(3)") - self.assertEqual(called, set([(2,), (3,)])) + self.assertEqual(called, {(2,), (3,)}) class ErrorTransformer(ast.NodeTransformer): """Throws an error when it sees a number.""" @@ -799,12 +799,12 @@ def test_user_variables(): ip.display_formatter.active_types = ip.display_formatter.format_types ip.user_ns['dummy'] = d = DummyRepr() - keys = set(['dummy', 'doesnotexist']) + keys = {'dummy', 'doesnotexist'} r = ip.user_expressions({ key:key for key in keys}) nt.assert_equal(keys, set(r.keys())) dummy = r['dummy'] - nt.assert_equal(set(['status', 'data', 'metadata']), set(dummy.keys())) + nt.assert_equal({'status', 'data', 'metadata'}, set(dummy.keys())) nt.assert_equal(dummy['status'], 'ok') data = dummy['data'] metadata = dummy['metadata'] @@ -832,7 +832,7 @@ def test_user_expression(): pprint.pprint(r) nt.assert_equal(set(r.keys()), set(query.keys())) a = r['a'] - nt.assert_equal(set(['status', 'data', 'metadata']), set(a.keys())) + nt.assert_equal({'status', 'data', 'metadata'}, set(a.keys())) nt.assert_equal(a['status'], 'ok') data = a['data'] metadata = a['metadata'] diff --git a/IPython/core/tests/test_profile.py b/IPython/core/tests/test_profile.py index b20aa0c..4c938ed 100644 --- a/IPython/core/tests/test_profile.py +++ b/IPython/core/tests/test_profile.py @@ -144,7 +144,7 @@ def test_list_profiles_in(): break if dec.unicode_paths: nt.assert_true(found_unicode) - nt.assert_equal(set(profiles), set(['foo', 'hello'])) + nt.assert_equal(set(profiles), {'foo', 'hello'}) def test_list_bundled_profiles():