Compute matches when text is a simple name. Return a list of all keywords, built-in functions and names currently defined in self.namespace that match.
(
self,
cursor_offset: int,
line: str,
*,
locals_: dict[str, Any] | None = None,
**kwargs: Any,
)
| 533 | |
| 534 | class GlobalCompletion(BaseCompletionType): |
| 535 | def matches( |
| 536 | self, |
| 537 | cursor_offset: int, |
| 538 | line: str, |
| 539 | *, |
| 540 | locals_: dict[str, Any] | None = None, |
| 541 | **kwargs: Any, |
| 542 | ) -> set[str] | None: |
| 543 | """Compute matches when text is a simple name. |
| 544 | Return a list of all keywords, built-in functions and names currently |
| 545 | defined in self.namespace that match. |
| 546 | """ |
| 547 | if locals_ is None: |
| 548 | return None |
| 549 | |
| 550 | r = self.locate(cursor_offset, line) |
| 551 | if r is None: |
| 552 | return None |
| 553 | |
| 554 | n = len(r.word) |
| 555 | matches = { |
| 556 | word for word in KEYWORDS if self.method_match(word, n, r.word) |
| 557 | } |
| 558 | for nspace in (builtins.__dict__, locals_): |
| 559 | for word, val in nspace.items(): |
| 560 | # if identifier isn't ascii, don't complete (syntax error) |
| 561 | if word is None: |
| 562 | continue |
| 563 | if ( |
| 564 | self.method_match(word, n, r.word) |
| 565 | and word != "__builtins__" |
| 566 | ): |
| 567 | matches.add(_callable_postfix(val, word)) |
| 568 | return matches if matches else None |
| 569 | |
| 570 | def locate(self, cursor_offset: int, line: str) -> LinePart | None: |
| 571 | return lineparts.current_single_word(cursor_offset, line) |
nothing calls this directly
no test coverage detected