From 3e8cd9f128074042496b8cf61ac26328f88889b5 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 4 Jan 2018 18:17:35 +0200 Subject: [PATCH] Use set literals --- jedi/api/keywords.py | 2 +- test/run.py | 2 +- test/test_api/test_api.py | 2 +- test/test_api/test_classes.py | 2 +- test/test_api/test_interpreter.py | 2 +- test/test_evaluate/test_imports.py | 2 +- test/test_utils.py | 6 +++--- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jedi/api/keywords.py b/jedi/api/keywords.py index a1bc4e7f..a4875c1c 100644 --- a/jedi/api/keywords.py +++ b/jedi/api/keywords.py @@ -52,7 +52,7 @@ def completion_names(evaluator, stmt, pos, module): def all_keywords(evaluator, pos=(0, 0)): - return set([Keyword(evaluator, k, pos) for k in keys]) + return {Keyword(evaluator, k, pos) for k in keys} def keyword(evaluator, string, pos=(0, 0)): diff --git a/test/run.py b/test/run.py index a3b0c0df..5eed56e7 100755 --- a/test/run.py +++ b/test/run.py @@ -177,7 +177,7 @@ class IntegrationTestCase(object): completions = self.script().completions() #import cProfile; cProfile.run('script.completions()') - comp_str = set([c.name for c in completions]) + comp_str = {c.name for c in completions} return compare_cb(self, comp_str, set(literal_eval(self.correct))) def run_goto_definitions(self, compare_cb): diff --git a/test/test_api/test_api.py b/test/test_api/test_api.py index c456c7cb..33f6f0c0 100644 --- a/test/test_api/test_api.py +++ b/test/test_api/test_api.py @@ -103,7 +103,7 @@ def test_completion_on_complex_literals(): _check_number('4.0j.', 'complex') # No dot no completion - I thought, but 4j is actually a literall after # which a keyword like or is allowed. Good times, haha! - assert (set([c.name for c in api.Script('4j').completions()]) == + assert ({c.name for c in api.Script('4j').completions()} == {'if', 'and', 'in', 'is', 'not', 'or'}) diff --git a/test/test_api/test_classes.py b/test/test_api/test_classes.py index 1e0d952d..3603a5f3 100644 --- a/test/test_api/test_classes.py +++ b/test/test_api/test_classes.py @@ -68,7 +68,7 @@ def test_basedefinition_type(definition): def test_basedefinition_type_import(): def get_types(source, **kwargs): - return set([t.type for t in Script(source, **kwargs).completions()]) + return {t.type for t in Script(source, **kwargs).completions()} # import one level assert get_types('import t') == {'module'} diff --git a/test/test_api/test_interpreter.py b/test/test_api/test_interpreter.py index 89a0bb75..419eae50 100644 --- a/test/test_api/test_interpreter.py +++ b/test/test_api/test_interpreter.py @@ -261,7 +261,7 @@ def test_completion_param_annotations(): a, b, c = c.params assert a._goto_definitions() == [] assert [d.name for d in b._goto_definitions()] == ['str'] - assert set([d.name for d in c._goto_definitions()]) == {'int', 'float'} + assert {d.name for d in c._goto_definitions()} == {'int', 'float'} def test_more_complex_instances(): diff --git a/test/test_evaluate/test_imports.py b/test/test_evaluate/test_imports.py index 738c1cdc..f66c66b7 100644 --- a/test/test_evaluate/test_imports.py +++ b/test/test_evaluate/test_imports.py @@ -157,7 +157,7 @@ def test_complete_on_empty_import(): assert 10 < len(Script("from . import classes", 1, 6, 'whatever.py').completions()) < 30 wanted = {'ImportError', 'import', 'ImportWarning'} - assert set([c.name for c in Script("import").completions()]) == wanted + assert {c.name for c in Script("import").completions()} == wanted assert len(Script("import import", path='').completions()) > 0 # 111 diff --git a/test/test_utils.py b/test/test_utils.py index 367decf4..2b4fd5a2 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -56,7 +56,7 @@ class TestSetupReadline(unittest.TestCase): string = 'os.path.join("a").upper' assert self.completions(string) == [string] - c = set(['os.' + d for d in dir(os) if d.startswith('ch')]) + c = {'os.' + d for d in dir(os) if d.startswith('ch')} assert set(self.completions('os.ch')) == set(c) finally: del self.namespace.sys @@ -73,7 +73,7 @@ class TestSetupReadline(unittest.TestCase): import os s = 'from os import ' - goal = set([s + el for el in dir(os)]) + goal = {s + el for el in dir(os)} # There are minor differences, e.g. the dir doesn't include deleted # items as well as items that are not only available on linux. assert len(set(self.completions(s)).symmetric_difference(goal)) < 20 @@ -85,7 +85,7 @@ class TestSetupReadline(unittest.TestCase): def test_preexisting_values(self): self.namespace.a = range(10) - assert set(self.completions('a.')) == set(['a.' + n for n in dir(range(1))]) + assert set(self.completions('a.')) == {'a.' + n for n in dir(range(1))} del self.namespace.a def test_colorama(self):