| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d3248ca commit eaef6d0
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -297,16 +297,16 @@ def matches(self, cursor_offset, line, **kwargs): | |||
| 297 | 297 | i -= 1 | |
| 298 | 298 | break | |
| 299 | 299 | methodtext = r.word[-i:] | |
| 300 | - matches = set( | ||
| 300 | + matches = { | ||
| 301 | 301 | "".join([r.word[:-i], m]) | |
| 302 | 302 | for m in self.attr_matches(methodtext, locals_) | |
| 303 | - ) | ||
| 303 | + } | ||
| 304 | 304 | ||
| 305 | - return set( | ||
| 305 | + return { | ||
| 306 | 306 | m | |
| 307 | 307 | for m in matches | |
| 308 | 308 | if few_enough_underscores(r.word.split(".")[-1], m.split(".")[-1]) | |
| 309 | - ) | ||
| 309 | + } | ||
| 310 | 310 | ||
| 311 | 311 | def locate(self, current_offset, line): | |
| 312 | 312 | return lineparts.current_dotted_attribute(current_offset, line) | |
@@ -376,11 +376,11 @@ def matches(self, cursor_offset, line, **kwargs): | |||
| 376 | 376 | except EvaluationError: | |
| 377 | 377 | return None | |
| 378 | 378 | if isinstance(obj, dict) and obj.keys(): | |
| 379 | - matches = set( | ||
| 379 | + matches = { | ||
| 380 | 380 | "{0!r}]".format(k) | |
| 381 | 381 | for k in obj.keys() | |
| 382 | 382 | if repr(k).startswith(r.word) | |
| 383 | - ) | ||
| 383 | + } | ||
| 384 | 384 | return matches if matches else None | |
| 385 | 385 | else: | |
| 386 | 386 | return None | |
@@ -403,7 +403,7 @@ def matches(self, cursor_offset, line, **kwargs): | |||
| 403 | 403 | return None | |
| 404 | 404 | if "class" not in current_block: | |
| 405 | 405 | return None | |
| 406 | - return set(name for name in MAGIC_METHODS if name.startswith(r.word)) | ||
| 406 | + return {name for name in MAGIC_METHODS if name.startswith(r.word)} | ||
| 407 | 407 | ||
| 408 | 408 | def locate(self, current_offset, line): | |
| 409 | 409 | return lineparts.current_method_definition_name(current_offset, line) | |
@@ -456,11 +456,11 @@ def matches(self, cursor_offset, line, **kwargs): | |||
| 456 | 456 | if r is None: | |
| 457 | 457 | return None | |
| 458 | 458 | if argspec: | |
| 459 | - matches = set( | ||
| 459 | + matches = { | ||
| 460 | 460 | name + "=" | |
| 461 | 461 | for name in argspec[1][0] | |
| 462 | 462 | if isinstance(name, str) and name.startswith(r.word) | |
| 463 | - ) | ||
| 463 | + } | ||
| 464 | 464 | matches.update( | |
| 465 | 465 | name + "=" | |
| 466 | 466 | for name in argspec[1][4] | |
@@ -494,7 +494,7 @@ def matches(self, cursor_offset, line, **kwargs): | |||
| 494 | 494 | ||
| 495 | 495 | # strips leading dot | |
| 496 | 496 | matches = [m[1:] for m in self.attr_lookup(obj, "", attr.word)] | |
| 497 | - return set(m for m in matches if few_enough_underscores(attr.word, m)) | ||
| 497 | + return {m for m in matches if few_enough_underscores(attr.word, m)} | ||
| 498 | 498 | ||
| 499 | 499 | ||
| 500 | 500 | try: | |
@@ -547,7 +547,7 @@ def matches(self, cursor_offset, line, **kwargs): | |||
| 547 | 547 | return None | |
| 548 | 548 | else: | |
| 549 | 549 | # case-sensitive matches only | |
| 550 | - return set(m for m in matches if m.startswith(first_letter)) | ||
| 550 | + return {m for m in matches if m.startswith(first_letter)} | ||
| 551 | 551 | ||
| 552 | 552 | def locate(self, cursor_offset, line): | |
| 553 | 553 | start = self._orig_start | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,7 +56,7 @@ def module_matches(cw, prefix=""): | |||
| 56 | 56 | if (name.startswith(full) and name.find(".", len(full)) == -1) | |
| 57 | 57 | ) | |
| 58 | 58 | if prefix: | |
| 59 | - return set(match[len(prefix) + 1 :] for match in matches) | ||
| 59 | + return {match[len(prefix) + 1 :] for match in matches} | ||
| 60 | 60 | else: | |
| 61 | 61 | return set(matches) | |
| 62 | 62 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,7 +110,7 @@ def test_two_completers_get_both(self): | |||
| 110 | 110 | a = self.completer(["a"]) | |
| 111 | 111 | b = self.completer(["b"]) | |
| 112 | 112 | cumulative = autocomplete.CumulativeCompleter([a, b]) | |
| 113 | - self.assertEqual(cumulative.matches(3, "abc"), set(["a", "b"])) | ||
| 113 | + self.assertEqual(cumulative.matches(3, "abc"), {"a", "b"}) | ||
| 114 | 114 | ||
| 115 | 115 | ||
| 116 | 116 | class TestFilenameCompletion(unittest.TestCase): | |
@@ -187,7 +187,7 @@ def test_set_of_keys_returned_when_matches_found(self): | |||
| 187 | 187 | com = autocomplete.DictKeyCompletion() | |
| 188 | 188 | local = {"d": {"ab": 1, "cd": 2}} | |
| 189 | 189 | self.assertSetEqual( | |
| 190 | - com.matches(2, "d[", locals_=local), set(["'ab']", "'cd']"]) | ||
| 190 | + com.matches(2, "d[", locals_=local), {"'ab']", "'cd']"} | ||
| 191 | 191 | ) | |
| 192 | 192 | ||
| 193 | 193 | def test_none_returned_when_eval_error(self): | |
@@ -254,27 +254,27 @@ def setUpClass(cls): | |||
| 254 | 254 | def test_att_matches_found_on_instance(self): | |
| 255 | 255 | self.assertSetEqual( | |
| 256 | 256 | self.com.matches(2, "a.", locals_={"a": Foo()}), | |
| 257 | - set(["a.method", "a.a", "a.b"]), | ||
| 257 | + {"a.method", "a.a", "a.b"}, | ||
| 258 | 258 | ) | |
| 259 | 259 | ||
| 260 | 260 | def test_descriptor_attributes_not_run(self): | |
| 261 | 261 | com = autocomplete.AttrCompletion() | |
| 262 | 262 | self.assertSetEqual( | |
| 263 | 263 | com.matches(2, "a.", locals_={"a": Properties()}), | |
| 264 | - set(["a.b", "a.a", "a.method", "a.asserts_when_called"]), | ||
| 264 | + {"a.b", "a.a", "a.method", "a.asserts_when_called"}, | ||
| 265 | 265 | ) | |
| 266 | 266 | ||
| 267 | 267 | def test_custom_get_attribute_not_invoked(self): | |
| 268 | 268 | com = autocomplete.AttrCompletion() | |
| 269 | 269 | self.assertSetEqual( | |
| 270 | 270 | com.matches(2, "a.", locals_={"a": OverriddenGetattribute()}), | |
| 271 | - set(["a.b", "a.a", "a.method"]), | ||
| 271 | + {"a.b", "a.a", "a.method"}, | ||
| 272 | 272 | ) | |
| 273 | 273 | ||
| 274 | 274 | def test_slots_not_crash(self): | |
| 275 | 275 | com = autocomplete.AttrCompletion() | |
| 276 | 276 | self.assertSetEqual( | |
| 277 | - com.matches(2, "A.", locals_={"A": Slots}), set(["A.b", "A.a"]), | ||
| 277 | + com.matches(2, "A.", locals_={"A": Slots}), {"A.b", "A.a"}, | ||
| 278 | 278 | ) | |
| 279 | 279 | ||
| 280 | 280 | ||
@@ -286,7 +286,7 @@ def setUpClass(cls): | |||
| 286 | 286 | def test_att_matches_found_on_instance(self): | |
| 287 | 287 | self.assertSetEqual( | |
| 288 | 288 | self.com.matches(5, "a[0].", locals_={"a": [Foo()]}), | |
| 289 | - set(["method", "a", "b"]), | ||
| 289 | + {"method", "a", "b"}, | ||
| 290 | 290 | ) | |
| 291 | 291 | ||
| 292 | 292 | def test_other_getitem_methods_not_called(self): | |
@@ -299,7 +299,7 @@ def __getitem__(inner_self, i): | |||
| 299 | 299 | def test_tuples_complete(self): | |
| 300 | 300 | self.assertSetEqual( | |
| 301 | 301 | self.com.matches(5, "a[0].", locals_={"a": (Foo(),)}), | |
| 302 | - set(["method", "a", "b"]), | ||
| 302 | + {"method", "a", "b"}, | ||
| 303 | 303 | ) | |
| 304 | 304 | ||
| 305 | 305 | @unittest.skip("TODO, subclasses do not complete yet") | |
@@ -309,7 +309,7 @@ class ListSubclass(list): | |||
| 309 | 309 | ||
| 310 | 310 | self.assertSetEqual( | |
| 311 | 311 | self.com.matches(5, "a[0].", locals_={"a": ListSubclass([Foo()])}), | |
| 312 | - set(["method", "a", "b"]), | ||
| 312 | + {"method", "a", "b"}, | ||
| 313 | 313 | ) | |
| 314 | 314 | ||
| 315 | 315 | def test_getitem_not_called_in_list_subclasses_overriding_getitem(self): | |
@@ -322,13 +322,13 @@ def __getitem__(inner_self, i): | |||
| 322 | 322 | def test_literals_complete(self): | |
| 323 | 323 | self.assertSetEqual( | |
| 324 | 324 | self.com.matches(10, "[a][0][0].", locals_={"a": (Foo(),)}), | |
| 325 | - set(["method", "a", "b"]), | ||
| 325 | + {"method", "a", "b"}, | ||
| 326 | 326 | ) | |
| 327 | 327 | ||
| 328 | 328 | def test_dictionaries_complete(self): | |
| 329 | 329 | self.assertSetEqual( | |
| 330 | 330 | self.com.matches(7, 'a["b"].', locals_={"a": {"b": Foo()}}), | |
| 331 | - set(["method", "a", "b"]), | ||
| 331 | + {"method", "a", "b"}, | ||
| 332 | 332 | ) | |
| 333 | 333 | ||
| 334 | 334 | ||
@@ -391,7 +391,7 @@ def test_completions_starting_with_different_cases(self): | |||
| 391 | 391 | ["adsf"], | |
| 392 | 392 | [Comp("Abc", "bc"), Comp("ade", "de")], | |
| 393 | 393 | ) | |
| 394 | - self.assertSetEqual(matches, set(["ade"])) | ||
| 394 | + self.assertSetEqual(matches, {"ade"}) | ||
| 395 | 395 | ||
| 396 | 396 | def test_issue_544(self): | |
| 397 | 397 | com = autocomplete.MultilineJediCompletion() | |
@@ -410,12 +410,12 @@ def function(): | |||
| 410 | 410 | ||
| 411 | 411 | self.assertEqual( | |
| 412 | 412 | self.com.matches(8, "function", locals_={"function": function}), | |
| 413 | - set(("function(",)), | ||
| 413 | + {"function("}, | ||
| 414 | 414 | ) | |
| 415 | 415 | ||
| 416 | 416 | def test_completions_are_unicode(self): | |
| 417 | 417 | for m in self.com.matches(1, "a", locals_={"abc": 10}): | |
| 418 | - self.assertIsInstance(m, type(u"")) | ||
| 418 | + self.assertIsInstance(m, type("")) | ||
| 419 | 419 | ||
| 420 | 420 | def test_mock_kwlist(self): | |
| 421 | 421 | with mock.patch.object(keyword, "kwlist", new=["abcd"]): | |
@@ -435,11 +435,11 @@ def func(apple, apricot, banana, carrot): | |||
| 435 | 435 | argspec = ["func", argspec, False] | |
| 436 | 436 | com = autocomplete.ParameterNameCompletion() | |
| 437 | 437 | self.assertSetEqual( | |
| 438 | - com.matches(1, "a", argspec=argspec), set(["apple=", "apricot="]) | ||
| 438 | + com.matches(1, "a", argspec=argspec), {"apple=", "apricot="} | ||
| 439 | 439 | ) | |
| 440 | 440 | self.assertSetEqual( | |
| 441 | - com.matches(2, "ba", argspec=argspec), set(["banana="]) | ||
| 441 | + com.matches(2, "ba", argspec=argspec), {"banana="} | ||
| 442 | 442 | ) | |
| 443 | 443 | self.assertSetEqual( | |
| 444 | - com.matches(3, "car", argspec=argspec), set(["carrot="]) | ||
| 444 | + com.matches(3, "car", argspec=argspec), {"carrot="} | ||
| 445 | 445 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,13 +18,13 @@ def tearDown(self): | |||
| 18 | 18 | ||
| 19 | 19 | def test_simple_completion(self): | |
| 20 | 20 | self.assertSetEqual( | |
| 21 | - importcompletion.complete(10, "import zza"), set(["zzabc", "zzabd"]) | ||
| 21 | + importcompletion.complete(10, "import zza"), {"zzabc", "zzabd"} | ||
| 22 | 22 | ) | |
| 23 | 23 | ||
| 24 | 24 | def test_package_completion(self): | |
| 25 | 25 | self.assertSetEqual( | |
| 26 | 26 | importcompletion.complete(13, "import zzabc."), | |
| 27 | - set(["zzabc.e", "zzabc.f"]), | ||
| 27 | + {"zzabc.e", "zzabc.f"}, | ||
| 28 | 28 | ) | |
| 29 | 29 | ||
| 30 | 30 | ||
@@ -43,15 +43,15 @@ def tearDownClass(cls): | |||
| 43 | 43 | ||
| 44 | 44 | def test_from_attribute(self): | |
| 45 | 45 | self.assertSetEqual( | |
| 46 | - importcompletion.complete(19, "from sys import arg"), set(["argv"]) | ||
| 46 | + importcompletion.complete(19, "from sys import arg"), {"argv"} | ||
| 47 | 47 | ) | |
| 48 | 48 | ||
| 49 | 49 | def test_from_attr_module(self): | |
| 50 | 50 | self.assertSetEqual( | |
| 51 | - importcompletion.complete(9, "from os.p"), set(["os.path"]) | ||
| 51 | + importcompletion.complete(9, "from os.p"), {"os.path"} | ||
| 52 | 52 | ) | |
| 53 | 53 | ||
| 54 | 54 | def test_from_package(self): | |
| 55 | 55 | self.assertSetEqual( | |
| 56 | - importcompletion.complete(17, "from xml import d"), set(["dom"]) | ||
| 56 | + importcompletion.complete(17, "from xml import d"), {"dom"} | ||
| 57 | 57 | ) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments