forked from VimPlug/jedi
Use set literals
This commit is contained in:
@@ -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)):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'})
|
||||
|
||||
|
||||
|
||||
@@ -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'}
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user